Skip to content

fix(deno): fall back to close() in peer.terminate() - #216

Closed
nitedani wants to merge 1 commit into
h3js:mainfrom
nitedani:fix/deno-terminate
Closed

nitedani wants to merge 1 commit into
h3js:mainfrom
nitedani:fix/deno-terminate

Conversation

@nitedani

Copy link
Copy Markdown

Claude Opus 5.5 (medium effort) wrote this; Opus 5.5 (medium effort) reviewed it.
State: draft (the CI run on this branch is the last check before I mark it ready)

On Deno, calling peer.terminate() crashes the server: the Deno peer calls terminate() on Deno's WebSocket, which has none, and the TypeError is uncaught. This PR removes that override, so the Deno peer uses the default Peer.terminate(), which calls close(), as the Cloudflare and SSE peers already do.

A hook calls peer.terminate() What happens
Deno, main error: Uncaught TypeError: this._internal.ws.terminate is not a function, and the Deno process exits
Deno, this PR the connection closes and the server keeps serving

The line at fault: src/adapters/deno.ts#L143-L145. The default it now falls back to: src/peer.ts#L172-L175. Deno's WebSocket has no abrupt close (typeof WebSocket.prototype.terminate is "undefined" on Deno 2.9.8). So the compatibility table now marks Deno's terminate() with footnote 2, "close() will be used for compatibility". I gave the Cloudflare Durable Objects cell the same footnote, because that peer also falls back to close().

The new shared test, "peer.terminate() closes the connection", checks that the client sees the close and that the server still answers HTTP afterwards. On main it fails on Deno with TypeError: fetch failed, because the server process has died. On this branch (fe681d0) it passes on Deno 2.9.8, Bun 1.4.3, Node, uWS (v20.48.0 locally), Vercel and Cloudflare Durable Objects. It skips SSE, because EventSource has no close event, and Cloudflare without Durable Objects, where locally (wrangler 4.151.1) the client saw no close within 4 s of the server's close().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

@nitedani 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 21, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

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

@nitedani

Copy link
Copy Markdown
Author

Claude Opus 5.5 (medium effort) wrote this; Opus 5.5 (medium effort) reviewed it.

The red Vercel check isn't from this change: Vercel asks for authorization to deploy any fork's PR, as on #213 and #212. The ci workflow waits for a maintainer's approval.

@pi0 pi0 closed this Oct 21, 2026
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.

2 participants