Skip to content

fix(netlify): forward event.waitUntil to the Netlify context - #5144

Open
onmax wants to merge 1 commit into
nitrojs:mainfrom
onmax:fix/netlify-wait-until
Open

onmax wants to merge 1 commit into
nitrojs:mainfrom
onmax:fix/netlify-wait-until

Conversation

@onmax

@onmax onmax commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

resolves #5143

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

On Netlify, event.waitUntil() registers nothing. Netlify passes context.waitUntil to Functions and Edge Functions, but the netlify entry ignores its second argument and netlify-edge doesn't set req.waitUntil.

This PR sets req.waitUntil from the Netlify context in both entries, the same way the Cloudflare and Vercel entries do. The two new tests in test/presets/netlify.test.ts call the built handlers with a waitUntil spy. They fail on main and pass here. The edge test runs on Deno, like the existing one.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@onmax
onmax requested a review from pi0 as a code owner November 16, 2026 19:28
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@onmax is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Netlify server and edge handlers now forward context.waitUntil to the request when req.waitUntil is unset. Tests cover the forwarding behavior for both handlers.

Changes: Netlify waitUntil forwarding

Layer / File(s) Summary
Forward context waitUntil to requests
src/presets/netlify/runtime/netlify.ts, src/presets/netlify/runtime/netlify-edge.ts, test/presets/netlify.test.ts
Both handlers assign the bound context.waitUntil method only when req.waitUntil is unset. Tests verify the server handler passes a Promise to the callback and the edge handler invokes its callback once.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 02c11

This change forwards waitUntil to the Netlify context so background work registered with event.waitUntil is honored. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title follows the conventional commits format with the type "fix" and the scope "netlify". It describes the main change: the Netlify entries now forward event.waitUntil to the Netlify context. The…
Description check Passed The description links issue #5143, marks the change as a bug fix, and explains that the netlify and netlify-edge entries ignore the Netlify context waitUntil. It also describes the two new tests. This…
Linked Issues check Passed Issue #5143 requires forwarding Netlify's context.waitUntil to the request in both the netlify and netlify-edge entries. The diff at head sets req.waitUntil in both entries. In `src/presets/ne…
Out of Scope Changes check Passed The whole-PR diff against merge base 749b12b touches only src/presets/netlify/runtime/netlify.ts, src/presets/netlify/runtime/netlify-edge.ts, and test/presets/netlify.test.ts. The netlify.ts …
Full details: Title check

Explanation

The title follows the conventional commits format with the type "fix" and the scope "netlify". It describes the main change: the Netlify entries now forward event.waitUntil to the Netlify context. The title matches the changeset and the linked issue.

Full details: Description check

Explanation

The description links issue #5143, marks the change as a bug fix, and explains that the netlify and netlify-edge entries ignore the Netlify context waitUntil. It also describes the two new tests. This matches the changeset.

Full details: Linked Issues check

Explanation

Issue #5143 requires forwarding Netlify's context.waitUntil to the request in both the netlify and netlify-edge entries. The diff at head sets req.waitUntil in both entries. In src/presets/netlify/runtime/netlify.ts, the handler now accepts context?: Context and sets req.waitUntil ??= context?.waitUntil?.bind(context). In src/presets/netlify/runtime/netlify-edge.ts, it sets req.waitUntil ??= context.waitUntil?.bind(context). This matches the Cloudflare and Vercel pattern named in the issue. The PR adds Node and Deno tests in test/presets/netlify.test.ts that call the built handlers with a waitUntil spy. The test file was not read directly; this result relies on the PR summary for the test content. The coding requirement is met by the source changes.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against merge base 749b12b touches only src/presets/netlify/runtime/netlify.ts, src/presets/netlify/runtime/netlify-edge.ts, and test/presets/netlify.test.ts. The netlify.ts change also adds a type-only import of Context from @netlify/functions, which supports the new parameter. All changes serve the objective of forwarding waitUntil in the two Netlify entries. No unrelated change was found.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bfccd3a0-210f-4489-91f4-f18fbbfb81c9
Commits

Reviewing files that changed from the base of the PR and between 749b12b and 02c11ed.

Files selected for processing: 3

  • src/presets/netlify/runtime/netlify-edge.ts
  • src/presets/netlify/runtime/netlify.ts
  • test/presets/netlify.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@5144

commit: 02c11ed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

netlify: event.waitUntil doesn't reach Netlify's context.waitUntil

1 participant