Cloudflare asyncContext support, how to enable?
Describe the change
I see a lot of efforts to make the experimental feature asyncContext introduced here to work on cloudflare workers.
experimental: {
asyncContext: true,
},
My code depends on this flag but unfortunatly I find no documentation / way to add support for this to may cloudflare worker application.
In wrangler.toml I have this:
compatibility_flags = [ "nodejs_compat" ]
In the documentation of unjs/unenv I find no clear instruction how to use the preset.
I build and deploy my application like this:
NITRO_PRESET=cloudflare nuxt build
But this is obviously not enough because the application still crashing because asyncContext is not working / enabled / polyfilled.
I highly appreciate any documentation how to enable / use the preset with nuxt.
URLs
No response
Additional information
- [ ] Would you be willing to help?
Adding the following config might have the magic.
export default defineNuxtConfig({
// other config...
nitro: {
preset: "cloudflare-pages",
unenv: cloudflare,
experimental: {
wasm: true,
asyncContext: true,
},
},
// other config...
})
But it's now still having some issue for Cloudflare Pages. useEvent().context.cloudflare might sometimes be undefined
Please followup https://github.com/nitrojs/nitro/issues/1943#issuecomment-2573016133 for latest usage and updates.