Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent vitest from hanging when using cloudflare/cloudflare-workers #12306

Closed
wants to merge 11 commits into from

Conversation

wooseopkim
Copy link

Adapter.emulate is a property used for adapter-cloudflare and adapter-cloudflare-workers. Because it is invoked earlier than needed, vitest runs hang as the Miniflare instance is not released. This PR makes Adapter.emulator called right before its return value is needed. prerender code is changed too, but it seems that adapter-cloudflare/cloudflare-workers don't allow pages to be prerendered. Return type of dev was changed because of ESLint error banning async functions without any awaits. It still returns an allowed type.

To make sure dev/preview server works with no problems, I've visually checked the rendered output of packages/kit/test/apps/cloudflare by running dev and build/preview. Also I've added a Playwright test to make sure the page is properly rendered and able to connect to Cloudflare KV namespaces.

Fixes #12305.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Jun 6, 2024

🦋 Changeset detected

Latest commit: 0faac07

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}'],
// https://github.com/sveltejs/kit/issues/12305
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is confusing. it seems to be saying that the teardownTimeout option is added to workaround issue #12305. however, that issue would be closed by this PR. can you add some text to go with the link and give some context?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benmccann Actually this is not necessary at all. It has the default value of 10000 or 10 seconds. I didn't want to make the test take 10 seconds longer, which happens when this fix goes broken and the test case fails. Do you think I can remove this entirely, or should I write in detail why I specified smaller value than the default in this case?

Copy link
Author

@wooseopkim wooseopkim Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the former approach, i.e. removing the timeout field.

@wooseopkim wooseopkim requested a review from benmccann July 10, 2024 13:54
@wooseopkim
Copy link
Author

@benmccann Hi, here's a friendly reminder about this PR.

@dummdidumm
Copy link
Member

Thank you for the PR - we went with #12830 instead, so closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vitest hangs when using adapter-cloudflare
4 participants