Files
bun.sh/src/http
Claude Bot 736d9917ef ws: implement upgrade and unexpected-response events
Implements support for the `upgrade` and `unexpected-response` events in
the `ws` package polyfill. This enables Playwright's `chromium.connectOverCDP()`
and other tools that rely on these events to work correctly with Bun.

Changes:
- Add `upgradeStatusCode` property to native WebSocket that stores the HTTP
  status code from the upgrade handshake
- Pass the status code from the HTTP upgrade response through Zig to C++
- Update ws.js polyfill to emit `upgrade` event before `open` event with
  the actual status code from the native WebSocket
- Emit `unexpected-response` event on connection errors for compatibility
- Add TypeScript types for the new `upgradeStatusCode` property
- Add regression tests for the new events

The `upgrade` event provides a response object with `statusCode`,
`statusMessage`, and `headers` properties. Headers are currently empty
but can be populated in a future enhancement if needed.

Fixes #9911

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 07:37:09 +00:00
..
2025-11-10 14:38:26 -08:00
2025-11-19 21:17:51 -08:00
2025-10-06 05:39:22 -07:00