kit icon indicating copy to clipboard operation
kit copied to clipboard

docs: mention `nodejs_als` compatibility flag

Open max-lt opened this issue 8 months ago • 7 comments

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.

max-lt avatar Mar 18 '25 08:03 max-lt

⚠️ 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

changeset-bot[bot] avatar Mar 18 '25 08:03 changeset-bot[bot]

Preview: https://svelte-dev-git-preview-kit-13605-svelte.vercel.app/

svelte-docs-bot[bot] avatar Mar 18 '25 08:03 svelte-docs-bot[bot]

I think this may no longer be necessary because of https://github.com/sveltejs/kit/pull/13607

benmccann avatar Mar 18 '25 16:03 benmccann

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.

Conduitry avatar Mar 18 '25 16:03 Conduitry

Thanks for this. Can you update the Cloudflare Workers adapter docs too?

teemingc avatar Mar 19 '25 06:03 teemingc

@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

benmccann avatar May 10 '25 18:05 benmccann

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.

teemingc avatar May 10 '25 22:05 teemingc

opened https://github.com/sveltejs/kit/pull/14189 as a possible alternative, basically forcing everyone to add this flag to avoid the warning

Rich-Harris avatar Aug 12 '25 20:08 Rich-Harris