Skip to content

feat(adapter/server): new Bunny.net Edge Scripting#179

Open
sandros94 wants to merge 17 commits intomainfrom
feat/bunny-adapter
Open

feat(adapter/server): new Bunny.net Edge Scripting#179
sandros94 wants to merge 17 commits intomainfrom
feat/bunny-adapter

Conversation

@sandros94
Copy link
Copy Markdown
Member

@sandros94 sandros94 commented Feb 12, 2026

Discussed privately, for Bunny.net Edge Scripting

Summary by CodeRabbit

  • New Features

    • Bunny.net Edge Scripting support: WebSocket adapter and server integration helpers for running WebSocket apps on Bunny.
  • Documentation

    • Added Bunny.net integration guide with examples and adapter configuration (protocol, idle timeout).
  • Exports

    • New public exports to import the Bunny adapter and server helpers.
  • Tests

    • Added a basic test validating the Bunny adapter export.

@sandros94 sandros94 self-assigned this Feb 12, 2026
@sandros94 sandros94 added the enhancement New feature or request label Feb 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Bunny.net WebSocket support: new Bunny adapter and types, server plugin and serve wrapper, package exports and build config updates, documentation, and a basic test. New adapter entrypoints and WSOptions.bunny configuration were introduced.

Changes

Cohort / File(s) Summary
Build & Exports
build.config.ts, package.json
Added "bunny" to adapters and servers in build config; added package exports ./adapters/bunny./dist/adapters/bunny.mjs and ./server/bunny./dist/server/bunny.mjs.
Adapter Implementation
src/adapters/bunny.ts
New Bunny adapter module: exported interfaces (BunnyAdapter, BunnyOptions, BunnyWebSocket, BunnyUpgradeResponse), default bunnyAdapter export, BunnyPeer class, handleUpgrade implementation, per-namespace peer tracking, and event/hook wiring (open, message, close, error).
Server types & integration
src/server/_types.ts, src/server/bunny.ts
Imported BunnyOptions; added bunny?: BunnyOptions to WSOptions. New plugin(wsOpts: WSOptions): ServerPlugin and serve(options: ServerWithWSOptions): Server to integrate the adapter and prepend upgrade middleware.
Documentation
docs/2.adapters/bunny.md
Added documentation describing manual integration with Bunny.net Edge Scripting, usage examples, adapter options (protocol, idleTimeout), and references to tests/source.
Tests
test/adapters/bunny.test.ts
Added basic test that dynamically imports the Bunny adapter and asserts the default export is defined and is a function.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibble at code where edge waves play,
A Bunny adapter hops in to relay.
Peers gather close, messages take flight,
Hooks hum softly through day and night.
Celebrate sockets — carrot patches bright! 🥕✨

🚥 Pre-merge checks | ✅ 3 | ❌ 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 (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
Title check ✅ Passed The title 'feat(adapter/server): new Bunny.net Edge Scripting' accurately describes the main changes, which add a new Bunny.net adapter and server integration with supporting documentation and configuration updates.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/bunny-adapter

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.

Copy link
Copy Markdown

@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: 2

🤖 Fix all issues with AI agents
In `@docs/2.adapters/bunny.md`:
- Around line 75-77: The docs reference to test/fixture/bunny.ts is broken;
either add a demo fixture file matching that path (test/fixture/bunny.ts) that
demonstrates the adapter usage or remove/update the ::read-more block in
docs/2.adapters/bunny.md so it only links to src/adapters/bunny.ts (and/or to an
existing demo file); ensure the docs no longer point to the nonexistent
test/fixture/bunny.ts link.

In `@src/adapters/bunny.ts`:
- Around line 96-99: The error handler for the Bunny socket is passing the
entire ErrorEvent object into WSError; update the
socket.addEventListener("error", (error) => {...}) callback to extract and pass
the underlying error (use event.error) into new WSError so you preserve real
error details—i.e., change the parameter name to event (or keep error but
reference error.error) and call peers.delete(peer); hooks.callHook("error",
peer, new WSError(event.error)); to mirror the Cloudflare adapter's behavior.
🧹 Nitpick comments (1)
src/adapters/bunny.ts (1)

22-30: JSDoc says @default 30 but no default is applied in code.

The JSDoc documents @default 30 (seconds), but the adapter code (lines 62-64) only passes idleTimeout through when explicitly set — it never applies a default of 30. This is fine if the intent is to document Bunny's platform default, but readers may expect the adapter itself to enforce this default. Consider clarifying the JSDoc (e.g., "Defaults to 30 on the Bunny platform") to avoid ambiguity.

Copy link
Copy Markdown

@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

🤖 Fix all issues with AI agents
In `@src/adapters/bunny.ts`:
- Around line 51-55: The handleUpgrade function should destructure
upgradeHeaders from the result of hooks.upgrade() so custom headers aren’t
discarded; update the call in handleUpgrade to pull { endResponse, context,
namespace, upgradeHeaders } from hooks.upgrade(), then apply those headers when
completing the WebSocket upgrade via the platform API (or, if Bunny’s
upgradeWebSocket does not accept custom response headers, add a clear
comment/doc note in handleUpgrade explaining the limitation and why
upgradeHeaders cannot be applied). Ensure you reference handleUpgrade and
hooks.upgrade() and, if using the request.upgradeWebSocket API, attempt to pass
upgradeHeaders there or document the incompatibility.

Copy link
Copy Markdown

@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

🤖 Fix all issues with AI agents
In `@src/adapters/bunny.ts`:
- Around line 106-110: Add a peers.delete(peer) call to the Bunny adapter's
socket "error" event handler to avoid leaking peers when an "error" fires
without a subsequent "close"; specifically, in the error listener where
hooks.callHook("error", peer, new WSError(error)) is invoked, first call
peers.delete(peer) (it's idempotent so safe to also keep the existing delete in
the "close" handler) so the peer is removed from the peers Set regardless of
whether "close" follows.
🧹 Nitpick comments (1)
src/adapters/bunny.ts (1)

58-78: upgradeHeaders is only consumed for protocol negotiation; all other headers are silently discarded.

You destructure upgradeHeaders (good — addresses the prior review), but the only value extracted from them is sec-websocket-protocol (line 67). Any other response headers the upgrade hook returns are lost because they're never attached to the response object returned by upgradeWebSocket. If this is a Bunny platform limitation, a brief comment would help future maintainers understand why.

@sandros94 sandros94 changed the title feat(adapters): new Bunny.net Edge Scripting feat(adapter/server): new Bunny.net Edge Scripting Feb 13, 2026
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