Skip to content

fix: only inherit waitUntil and platform context in fetch #3224

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

Merged
merged 7 commits into from
Mar 18, 2025
Merged

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Mar 15, 2025

nuxt/nuxt#31375

Fixing a regression (revealed) from #3155

When calling a fetch with a relative base URL in a server context, nitro uses an internal fetch mechanism without an actual network round trip.

Event context has to be (partially) shared so that platform-specific contexts like event.cf and event.waitUntil are inherited and work. However, we should never share other context keys (including the cached value of the route rule that corresponds to the main event, not the sub-event).

It was not revealed before because before #3155, the proxy route rule was kicking in before h3 route handler.

This PR fixes the root cause by only inheriting an internal namespace of the provider context + waitUntil

(Note: this PR only targets v2 as direct fetch mechanism being updated with h3 v2 migration)

@pi0 pi0 changed the title docs(deno-server): add compatibilityDate note (#3190) fix: only inherit platform context from direct fetch Mar 15, 2025
@pi0 pi0 added the v2 label Mar 15, 2025
Copy link

cloudflare-workers-and-pages bot commented Mar 15, 2025

Deploying nitrojs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0b156be
Status: ✅  Deploy successful!
Preview URL: https://18de2828.nitrojs.pages.dev
Branch Preview URL: https://fix-platform-ctx.nitrojs.pages.dev

View logs

@pi0 pi0 changed the title fix: only inherit platform context from direct fetch fix: only inherit platform context to direct fetch context Mar 15, 2025
@pi0 pi0 changed the title fix: only inherit platform context to direct fetch context fix: only inherit waitUntil and platform context in fetch Mar 18, 2025
@pi0 pi0 force-pushed the fix/platform-ctx branch from 312ec26 to d8853e2 Compare March 18, 2025 12:25
@pi0 pi0 merged commit 96e0b73 into v2 Mar 18, 2025
5 checks passed
@pi0 pi0 deleted the fix/platform-ctx branch March 18, 2025 12:32
@pi0 pi0 mentioned this pull request Mar 20, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant