Skip to content

feat(bunny): add support for native waitUntil#186

Merged
pi0 merged 1 commit intomainfrom
fix/bunny-use-native-wait-until
Feb 18, 2026
Merged

feat(bunny): add support for native waitUntil#186
pi0 merged 1 commit intomainfrom
fix/bunny-use-native-wait-until

Conversation

@sandros94
Copy link
Member

@sandros94 sandros94 commented Feb 18, 2026

Followup for #182

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced public Bunny.unstable.waitUntil API surface for managing asynchronous operations
    • BunnyServer now exposes a public waitUntil method

@sandros94 sandros94 self-assigned this Feb 18, 2026
@sandros94 sandros94 requested a review from pi0 as a code owner February 18, 2026 17:17
@sandros94 sandros94 added the enhancement New feature or request label Feb 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This PR refactors the Bunny adapter to introduce a public Bunny.unstable.waitUntil API surface, replacing the internal private wait mechanism. The BunnyServer class exposes a public waitUntil property wired to this new API, simplifies the close method to return a resolved promise, and removes the createWaitUntil dependency.

Changes

Cohort / File(s) Summary
API surface and namespace exports
src/adapters/bunny.ts
Introduces BunnySDKUnstable type and exposes Bunny.unstable export with waitUntil method for public consumption.
BunnyServer implementation refactoring
src/adapters/bunny.ts
Adds public waitUntil property to BunnyServer, wires constructor and request augmentation to delegate to Bunny.unstable.waitUntil, simplifies close() to return resolved promise without await, and removes private #wait field and createWaitUntil import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • pi0

Poem

🐰 A bouncy refactor hops into view,
Unstable.waitUntil, shiny and new!
Private hops out, public bounds in,
Promise resolution—the cleanup begins! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(bunny): add support for native waitUntil' accurately captures the main change: introducing native waitUntil API support as a public surface in the Bunny SDK.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/bunny-use-native-wait-until

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

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/h3js/srvx@186

commit: 86a765d

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/adapters/bunny.ts`:
- Around line 46-50: Guard accesses to the unstable namespace and avoid
duplicating the lambda: change uses of Bunny.unstable.waitUntil to use optional
chaining (e.g., Bunny.unstable?.waitUntil) and make this.waitUntil a safe
wrapper that checks Bunny.unstable before calling it; then reuse this.waitUntil
when defining request.waitUntil inside fetch instead of redefining the arrow
function. Update symbols: Bunny.unstable, this.waitUntil, fetch, and the
request.waitUntil property to perform a no-op or safe call when Bunny.unstable
is undefined.

Comment on lines +46 to +50
this.waitUntil = (promise: Promise<unknown>) => Bunny.unstable.waitUntil(promise);

this.fetch = (request: Request) => {
Object.defineProperties(request, {
waitUntil: { value: this.#wait?.waitUntil },
waitUntil: { value: (promise: Promise<unknown>) => Bunny.unstable.waitUntil(promise) },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing null-safety guard for Bunny.unstable; duplicate lambda.

Two concerns here:

1. No guard for Bunny.unstable (major): Bunny.unstable is accessed without optional chaining. Unlike Bunny.v1, which is guarded by Bunny.v1?.serve inside serve(), Bunny.unstable is never checked. If the runtime doesn't expose this namespace yet (e.g., on an older edge node during a phased rollout, or during local development with manual: true before serve() throws), any call to server.waitUntil() or request.waitUntil() from a request handler will throw TypeError: Cannot read properties of undefined (reading 'waitUntil'). Since the unstable namespace name itself signals it could be removed or absent, defensive access is warranted.

2. Duplicate lambda (optional): The same arrow function is defined twice — once at line 46 for this.waitUntil and again at line 50 for the request property. The fetch handler can simply reuse this.waitUntil.

🛡️ Proposed fix: optional chaining + dedup lambda
-   this.waitUntil = (promise: Promise<unknown>) => Bunny.unstable.waitUntil(promise);
+   this.waitUntil = (promise: Promise<unknown>) => Bunny.unstable?.waitUntil(promise);

    this.fetch = (request: Request) => {
      Object.defineProperties(request, {
-       waitUntil: { value: (promise: Promise<unknown>) => Bunny.unstable.waitUntil(promise) },
+       waitUntil: { value: this.waitUntil },
        runtime: { enumerable: true, value: { name: "bunny" } },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adapters/bunny.ts` around lines 46 - 50, Guard accesses to the unstable
namespace and avoid duplicating the lambda: change uses of
Bunny.unstable.waitUntil to use optional chaining (e.g.,
Bunny.unstable?.waitUntil) and make this.waitUntil a safe wrapper that checks
Bunny.unstable before calling it; then reuse this.waitUntil when defining
request.waitUntil inside fetch instead of redefining the arrow function. Update
symbols: Bunny.unstable, this.waitUntil, fetch, and the request.waitUntil
property to perform a no-op or safe call when Bunny.unstable is undefined.

@pi0 pi0 changed the title fix(bunny): add support for native waitUntil feat(bunny): add support for native waitUntil Feb 18, 2026
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thnx!

@pi0 pi0 merged commit 4b03ea8 into main Feb 18, 2026
13 checks passed
@pi0 pi0 deleted the fix/bunny-use-native-wait-until branch February 18, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants