Skip to content

[WARNING] The package "node:async_hooks" wasn't found on the file system but is built into node. #13668

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

Open
frederichoule opened this issue Apr 2, 2025 · 4 comments · May be fixed by #13605
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. pkg:adapter-cloudflare

Comments

@frederichoule
Copy link

Describe the bug

After upgrading:

  • sveltekit: 2.19.1 to 2.20.3
  • svelte: 5.23.0 to 5.25.6

Cloudflare now complains that "node:async_hooks" is being imported by _worker.js. This notice wasn't there on previous builds/previous versions.

Image

Reproduction

You can create by creating a new Sveltekit project (using npx sv create) and deploying as Cloudflare pages.

Logs

System Info

N/A

Severity

annoyance

Additional Information

No response

@frederichoule
Copy link
Author

frederichoule commented Apr 2, 2025

Seems to be caused by #13582

@Conduitry
Copy link
Member

If you're not using getRequestEvent(), then you don't need to worry about this. If you are using it, then you should set the nodejs_compat flag, as mentioned in the warning.

@eltigerchino I think you were mentioning some way we could deal with this by having the adapter influence the configuration of the deployment? https://developers.cloudflare.com/workers/wrangler/configuration/#generated-wrangler-configuration

@Conduitry Conduitry added bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. pkg:adapter-cloudflare labels Apr 2, 2025
@frederichoule
Copy link
Author

frederichoule commented Apr 2, 2025

I'm not using getRequestEvent(), so it doesn't affect me (and I don't want/have the nodejs_compat flag).

But I still like to have clean logs without warnings :-)

@eltigerchino eltigerchino linked a pull request Apr 3, 2025 that will close this issue
@eltigerchino
Copy link
Member

@eltigerchino I think you were mentioning some way we could deal with this by having the adapter influence the configuration of the deployment? developers.cloudflare.com/workers/wrangler/configuration#generated-wrangler-configuration

Yes, that was the initial idea but it seems that generating a wrangler configuration is prone to getting out of sync with the user config if they don't re-run the build. Instead, the Cloudflare folks suggested adding an error message if the appropriate flags aren't set. Otherwise, we need to look at trying to treeshake this import away if the getRequestEvent() function isn't used.

I'd highly recommend enabling the nodejs_als compatibility flag in the meantime if you want to get rid of the warning. This doesn't seem to bundle any extra code in the worker from my testing compared to enabling the nodejs_compat flag which does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. pkg:adapter-cloudflare
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants