Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug] Concurrent requests with the cloudflare wrappers #713

Closed
vicb opened this issue Jan 27, 2025 · 1 comment · Fixed by #733 · May be fixed by #729
Closed

[Bug] Concurrent requests with the cloudflare wrappers #713

vicb opened this issue Jan 27, 2025 · 1 comment · Fixed by #733 · May be fixed by #729
Assignees

Comments

@vicb
Copy link
Contributor

vicb commented Jan 27, 2025

There is a bug when using the cloudflare wrappers (cloudflare-node and cloudflare-edge)

It will manifest with the following log:

workerd/io/worker.c++:1195: warning: NOSENTRY Warning: Cross Request Promise Resolve

The root cause is that we share ctx.waitUntil() on globalThis.openNextWaitUntil:

globalThis.openNextWaitUntil = ctx.waitUntil.bind(ctx);

The problem here is that ctx.waitUntil is request specific but globalThis is shared across requests. We should add it to ALS instead.

I hope I'll get to fixing this later today, otherwise in the next few days.

Edit: the warning has been removed from workerd in cloudflare/workerd#3388, you need to run the e2e with workerd v1.20250121.0 to see the warning

@vicb vicb self-assigned this Jan 27, 2025
@conico974
Copy link
Contributor

Hmm i see, not sure we can easily reuse the current OpenNext ALS without some breaking change. Reusing it probably means that we'd have to initialize the ALS on every wrapper and that's not something that i'd like to do.

Maybe it would make sense to define the cloudflare context inside the wrapper directly ?
Another option would be to create one ALS only if you can't find the already defined one (i.e. (globalThis as any)[Symbol.for("__cloudflare-context__")])

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
2 participants