test(bun): expect 1009 for oversized WebSocket frames on Bun 1.4+
CI picked up Bun 1.4.4 (`oven-sh/setup-bun@v2`, latest), which now sends a real `1009` close frame when `maxPayloadLength` refuses a frame. Bun 1.3 dropped the connection instead, so the peer saw `1006` — the difference D1 documented and these two assertions pinned on purpose so a Bun upgrade would be noticed. It was: `runtimes (bun)` fails on develop. The assertion now follows `Bun.version` (1006 before 1.4, 1009 from 1.4), so a further change in either direction still fails. JSDoc, README and the #107 CHANGELOG entry say which Bun versions do what. Verified with Bun 1.3.14 and 1.4.4 (26/26 each); lint, format, typecheck, npm test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
5 files changed
+15
-13
No files matched your search
+2
-2
@@ -108,8 +108,8 @@ export async function serveBun(app: App, options?: BunServeShortOptions): Promis
|
||||
},
|
||||
websocket: {
|
||||
// The pre-buffer half of `limits.maxWsMessageBytes`: Bun refuses an oversized frame before
|
||||
// assembling it. It drops the connection without a close frame, so the peer sees 1006 rather
|
||||
// than 1009 — verified on Bun 1.3, and the price of not buffering the message at all.
|
||||
// assembling it. Up to Bun 1.3 it dropped the connection without a close frame, so the peer
|
||||
// saw 1006 rather than 1009 — the price of not buffering the message at all. Bun 1.4 sends 1009.
|
||||
// `app.upgrade` checks the same bound again on the decoded text.
|
||||
maxPayloadLength:
|
||||
(app as { [WS_MAX_MESSAGE_BYTES]?: number })[WS_MAX_MESSAGE_BYTES] ?? DEFAULT_MAX_WS_MESSAGE_BYTES,
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ export interface RequestLimits {
|
||||
* a fragmented message counts as a whole. Must be a positive integer, or `createApp` throws.
|
||||
*
|
||||
* Node and Bun refuse an oversized frame before buffering it (`ws`'s `maxPayload`, Bun's
|
||||
* `maxPayloadLength`). Bun then drops the connection without a close frame, so on Bun the peer
|
||||
* sees `1006` instead of `1009`. Deno and the edge offer no such option: there the runtime
|
||||
* `maxPayloadLength`). Before Bun 1.4, Bun then drops the connection without a close frame, so
|
||||
* the peer sees `1006` instead of `1009`; Bun 1.4 and later send `1009`. Deno and the edge offer no such option: there the runtime
|
||||
* receives the whole message first, so its memory is bounded by the platform's own cap, and this
|
||||
* limit is checked after receipt — the connection still closes `1009`.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user