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>
This was referenced Dec 2, 2026
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
fetchargument (the WorkersExecutionContext) on the seeded context behind aSymbol.for('@supabase/middleware:execution-context')key, the same way the context marker rides it. It is not actxkey, soctxstill carries only middleware contributions, and the one-time "not honored" warning is gone.waitUntil(ctx, promise). With an execution context it callsexecutionContext.waitUntil(promise)(as a method, so workerd'sthischeck holds). Without one it runs the promise unattached and logs a rejection withconsole.error, so middleware can call it on any host.seedContext(platformArg?, executionContext?)gains an optional second parameter, so a host embedding the engine can pass the execution context too. Existing callers are unaffected.ExecutionContextLiketype, README update for the entry signatures.Why
waitUntilis how Workers keep work running after the response is sent (telemetry, audit logs, cache revalidation). Today the entry drops it, so neither the middlewares in a stack nor the handler at the bottom can schedule background work without smuggling the execution context through some other channel.Closes #53
Testing
src/core/runtime.test.ts: promises from a middleware and from the handler reach the host's execution context through a pipeline and a composite, two concurrent requests keep their own execution contexts, the fallback logs a rejection, and an argument withoutwaitUntilis ignored.src/core/define-middleware.test.ts: the old warn-and-ignore test now checks that the third argument neither warns nor leaks intoctx.test/runtimes/workers: the built dist callswaitUntilinside workerd with the realExecutionContext.Ran locally:
pnpm format:check,pnpm lint,pnpm typecheck,pnpm typecheck:min,pnpm build,pnpm typecheck:consumer,pnpm smoke,pnpm check-exports,pnpm test(128 tests),pnpm test:workers,pnpm test:bun, and the JSR dry run. I did not runpnpm test:deno(no Deno locally); the Deno target never passes a third argument.Alternatives
ctx.waitUntil(promise). I went with an importable function because the README saysctxcarries no reserved framework key, and awaitUntilkey could collide with a middleware's contribution.getEnvsets the precedent for importable runtime access.passThroughOnExceptionis not exposed. AgetExecutionContext(ctx)accessor could expose it later if there is demand.Prior art: the better-supabase edge bridge stores the execution context on the seeded context under a private symbol and hands it to the handler.
🤖 Generated with Claude Code