Skip to content

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

@frederichoule

Description

@frederichoule

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

Activity

frederichoule

frederichoule commented on Apr 2, 2025

@frederichoule
Author

Seems to be caused by #13582

Conduitry

Conduitry commented on Apr 2, 2025

@Conduitry
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

added
bugSomething isn't working
p2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.
on Apr 2, 2025
frederichoule

frederichoule commented on Apr 2, 2025

@frederichoule
Author

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 commented on Apr 3, 2025

@eltigerchino
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.

added theissue type on Apr 3, 2025
penalosa

penalosa commented on Jul 14, 2025

@penalosa

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.

That's definitely a potential footgun, but if the user doesn't re-run the build their SvelteKit app will also be out of sync, so I'm not sure it's a blocking concern. Generated Wrangler configuration is the approach we're taking with the Cloudflare Vite plugin, and it's designed to solve problems like this (frameworks requiring deployment config that users don't necessarily need).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.pkg:adapter-cloudflare

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @frederichoule@Conduitry@penalosa@eltigerchino

      Issue actions

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