Repository navigation
Conversation
The entry call now keeps the third fetch argument on the seeded context behind a symbol instead of warning and dropping it. A new waitUntil(ctx, promise) hands background work to it from any middleware or the handler, and runs the promise unattached with a logged rejection when the host passed no execution context. Closes supabase#53 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Next.js calls proxy(request, event) with the event that carries waitUntil in second position, where the entry call expects bindings. The event was stored as the module-scoped platform env and its waitUntil could not be reached. A second argument with a waitUntil method is now kept as the execution context for waitUntil(ctx, promise) and is not captured as the platform env. A third argument still wins when both carry waitUntil. Refs supabase#53 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
seedContext(platformArg, executionContext?): when no execution context came as the third argument and the second argument has awaitUntilmethod, that argument is the execution context. It is kept on the seeded context forwaitUntil(ctx, promise)and is not stored as the module-scoped platform env thatgetEnvreads.waitUntil(Workers), nothing changes: the third argument is the execution context and the second is the bindings object.Why
Next.js calls
proxy(request, event), and theNextFetchEventin second position is the object withwaitUntil. Today the entry call takes it for the bindings object. I ran aproxy.tsthat hands(request, event)to adefineMiddlewarestack in a Next.js 16.5.0 app (next build,next start):maingetEnv("sourcePage")inside the stack/proxy(a field of the event)undefinedwaitUntil(ctx, promise)reachesevent.waitUntilI did not run #65 on its own in the app. By its code it treats the second argument as
maindoes and looks for the execution context in third position only, sowaitUntilwould fall back to running the promise unattached. There is no third argument on this host, so the "not honored" warning onmainnever fires either. The details and the reproduction are in #53 (comment).Bindings never carry a
waitUntilfunction, so the check does not change what Workers see. A second argument with awaitUntilproperty that is not a function is still captured as bindings.Refs #53
Testing
src/core/runtime.test.ts: an event-shaped second argument (class instance,waitUntilon the prototype, a string field of its own) receives the promises from a middleware and from the handler, its fields are not readable throughgetEnv, and bindings captured earlier survive; withwaitUntilon both arguments the third wins and the second stays the bindings object; a second argument without awaitUntilfunction is captured as before.pnpm format:check,pnpm lint,pnpm typecheck,pnpm typecheck:min,pnpm build,pnpm typecheck:consumer,pnpm smoke,pnpm check-exports,pnpm test(131 tests),pnpm test:workers,pnpm test:bunand the JSR dry run. All pass.pnpm test:deno(no Deno locally). I did not test Vercel or Netlify functions, whose handlers also take a secondcontextargument; I only claim Next.js.Not in this PR
The platform env is still one module-level slot, so the last entry call's second argument serves every later
getEnvcall. The issue comment proposes keeping the bindings on the seeded context too and an optionalgetEnv(key, ctx). That is an API addition and I have left it for your call.Overlap with other open PRs
#65 (the base of this branch) and #68 both edit
seedContextand the README environment section. #68 movesgetEnvto its own file and does not change the lines this commit adds.🤖 Generated with Claude Code