Skip to content

AsyncLocalStorage Next.js Error with Cloudflare Workers #18842

@logaretm

Description

@logaretm

Description

Initially reported by @tristanbes in this issue

I just had an outage on my production because of this. I am, as i'm typing this message, deleting all server side integration with sentry that I followed from your docs.

Cannot call this AsyncLocalStorage bound function outside of the request in which it was created.

Environment:

  • Next.js: 15.5.9
  • @opennextjs/cloudflare: 1.14.8
  • @sentry/nextjs: 10.33.0
  • Deployment: Cloudflare Workers
  • Cloudflare Workers compatibility_date: 2025-11-17
  • Cloudflare compatibility_flags: nodejs_compat, global_fetch_strictly_public

Symptoms encountered:

  • AsyncLocalStorage errors when using Sentry.captureRequestError in the onRequestError hook (maybe with addBreadcrumb too)
  • Server-side Sentry initialization causes silent failures or "Server failed to respond" errors

Current workaround:
I've removed all server-side Sentry integration (deleted sentry.server.config.ts and sentry.edge.config.ts) and only kept client-side error tracking via instrumentation-client.ts. Client-side Sentry works fine.

The withSentryConfig wrapper in next.config.ts still works for source map uploads and the /monitoring tunnel route.

Is there an ETA for OpenNext/Cloudflare Workers support? Would love to have full-stack observability back. Happy to help test any beta/canary versions.

I haven't reproduced it yet, but it might be related to #18700

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions