Skip to content

fix(generic): keep an existing request.waitUntil - #309

Merged
pi0 merged 1 commit into
h3js:mainfrom
kaanisthatyou:fix/generic-keep-wait-until
Oct 17, 2026
Merged

pi0 merged 1 commit into
h3js:mainfrom
kaanisthatyou:fix/generic-keep-wait-until

Conversation

@kaanisthatyou

@kaanisthatyou kaanisthatyou commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #306.

The generic adapter's fetch always redefined request.waitUntil. A platform waitUntil set on the request was replaced by the adapter's own, which only server.close() awaits. And since defineProperties makes the property non-configurable, a request passed through two generic servers threw TypeError: Cannot redefine property: waitUntil.

waitUntil is now only defined when the request does not already have one.

Tests: two new cases in test/generic.test.ts (platform waitUntil is kept; nested generic servers). Both fail on main and pass with the change. Full suite before/after differs only in these two; lint, format and typecheck pass.

Summary by CodeRabbit

  • Bug Fixes
    • Preserved an existing request handler for background tasks, including when requests pass through nested servers.

The generic adapter always redefined `request.waitUntil`, so a platform's
`waitUntil` was replaced by one that only `server.close()` awaits, and a
request passed through two generic servers threw "Cannot redefine
property: waitUntil".

Closes h3js#306

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaanisthatyou
kaanisthatyou requested a review from pi0 as a code owner October 4, 2026 09:05
@vercel

vercel Bot commented Oct 4, 2026

Copy link
Copy Markdown

@kaanisthatyou is attempting to deploy a commit to the unjs Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: da8c307b-219f-441d-a2bd-7f4f1ae449ce
📥 Commits

Reviewing files that changed from the base of the PR and between f74d220 and 1c1e3e3.

📒 Files selected for processing (2)
  • src/adapters/generic.ts
  • test/generic.test.ts

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


📝 Walkthrough

Walkthrough

The generic fetch handler now preserves a request’s existing function-valued waitUntil. Tests check promise forwarding and the response from a nested generic server.

Changes

Request waitUntil preservation

Layer / File(s) Summary
Preserve request waitUntil
src/adapters/generic.ts, test/generic.test.ts
The generic fetch handler assigns its own waitUntil only if the request does not already have a function-valued one. Tests check that the existing function remains in place and receives a promise, and that a nested generic server returns the inner response.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 1c1e3

The adapter preserves platform or outer-server waitUntil behavior while retaining its fallback. The supplied tests cover forwarding and nested requests; no concrete merge-blocking risk is evident.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 1c1e3

The change restores platform and outer-server ownership of background work without changing the handler pipeline. No introduced security vulnerability was established. Integration risk remains because closing the current generic server does not await work registered with a preserved external callback, and deployment-specific ownership assumptions are not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated effect is background-promise registration and completion ownership for requests passed through the generic adapter, including nested servers. The supplied evidence does not establish a tenant, credential, data-store, or environment-wide privilege expansion.

Trust Boundaries and Controls

  • observed — The adapter accepts any existing function-valued waitUntil without validating its provenance. It does not itself invoke that preserved callback or bypass the composed middleware pipeline. Whether an untrusted in-process component can supply requests is a deployment-boundary gap, not an established attack path.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving an existing request.waitUntil function in the generic adapter.
Linked Issues check ✅ Passed Issue #306 requires the generic adapter to preserve an existing platform request.waitUntil. src/adapters/generic.ts defines the adapter handler only when request.waitUntil is not a function. `te…
Out of Scope Changes check ✅ Passed The reported changes are limited to src/adapters/generic.ts and related tests in test/generic.test.ts. The implementation and tests directly address issue #306. No unrelated changes are shown by t…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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

A rabbit guards the promise stream,
The old waitUntil stays on the team.
Through nested servers, responses pass,
While carrots crunch beside the grass.
“Your promises travel as before!”
Then hops away to test once more.

Comment @coderabbitai help to get the list of available commands.

@h3js h3js temporarily blocked kaanisthatyou Oct 4, 2026
@pi0
pi0 merged commit 96be02b into h3js:main Oct 17, 2026
11 of 12 checks passed
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.

generic: fetch overrides existing request.waitUntil

2 participants