mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
## Summary Fixes a flaky test (`test-http-url.parse-https.request.js`) where `request.socket._secureEstablished` was intermittently `false` when the HTTP request handler was called on HTTPS servers. ## Root Cause The `isAuthorized` flag was stored in `HttpContextData::flags.isAuthorized`, which is **shared across all sockets** in the same context. This meant multiple concurrent TLS connections could overwrite each other's authorization state, and the value could be stale when read. ## Fix Moved the `isAuthorized` flag from the context-level `HttpContextData` to the per-socket `AsyncSocketData` base class. This ensures each socket has its own authorization state that is set correctly during its TLS handshake callback. ## Changes - **`AsyncSocketData.h`**: Added per-socket `bool isAuthorized` field - **`HttpContext.h`**: Updated handshake callback to set per-socket flag instead of context-level flag - **`JSNodeHTTPServerSocket.cpp`**: Updated `isAuthorized()` to read from per-socket `AsyncSocketData` (via `HttpResponseData` which inherits from it) ## Testing Ran the flaky test 50+ times with 100% pass rate. Also verified gRPC and HTTP2 tests still pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
Bun's fork of uWebSockets
Bun's HTTP & WebSocket server is based on uWebSockets. Thanks to @uNetworkingAB for the great work!