kit
kit copied to clipboard
docs: mention `nodejs_als` compatibility flag
Hello, I noticed some warning when running a cloudflare-adapter project with wrangler
npx wrangler pages dev .svelte-kit/cloudflare
▲ [WARNING] The package "node:async_hooks" wasn't found on the file system but is built into node.
Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility flag.
Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details. Imported
from:
- .wrangler/tmp/pages-mQuBz9/bundledWorker-0.48410322524810456.mjs
Seems due to the missing AsyncLocalStorage API in workers by default. I added some instructions to the doc to enable the required compatibility flag.
⚠️ No Changeset found
Latest commit: 2e27a3ec45603d22b99bc3281f2f8b4a98dc81cc
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Preview: https://svelte-dev-git-preview-kit-13605-svelte.vercel.app/
I think this may no longer be necessary because of https://github.com/sveltejs/kit/pull/13607
I think this may no longer be necessary because of https://github.com/sveltejs/kit/pull/13607
I would doubt it. The PR just removed the top-level await - the import of node:async_hooks is still present.
Thanks for this. Can you update the Cloudflare Workers adapter docs too?
@eltigerchino I just fixed the merge conflict on this one. Do you still think we should update the Cloudflare Workers docs since the two adapters have been merged? I see there's also a Cloudflare Workers section in the Cloudflare Adapter doc. You're more familiar with Cloudflare, so I thought you might have a good suggestion of what would need to be updated
Thank you!
Do you still think we should update the Cloudflare Workers docs since the two adapters have been merged?
We could because it should be the exact same as the Cloudflare docs so we can just copy and paste it.
I see there's also a Cloudflare Workers section in the Cloudflare Adapter doc. You're more familiar with Cloudflare, so I thought you might have a good suggestion of what would need to be updated
I think we might want to suggest having the compatibility flag added in the user's Wrangler config file over using the dashboard or CLI option so that it's always set up on deployment/dev. We might also want to explain it's only needed if using getRequestEvent asynchronously.
opened https://github.com/sveltejs/kit/pull/14189 as a possible alternative, basically forcing everyone to add this flag to avoid the warning