Conversation
There was a problem hiding this comment.
Adds binaryType property to WebSocket per WHATWG spec, gated behind the websocket_standard_binary_type compat flag.
Findings (ranked by severity):
-
[HIGH] Missing
binaryType_override infetch()upgrade path —http.c++:1562creates a WebSocket viajs.alloc<WebSocket>(kj::mv(webSocket))without applying the compat flag override. A worker doingconst resp = await fetch(url, {headers: {Upgrade: 'websocket'}}); resp.webSocket.accept();would getbinaryType === "arraybuffer"even with the flag enabled, and binary messages would be delivered asArrayBufferinstead ofBlob. -
[MEDIUM] Redundant
binaryType_initialization — The hibernation constructor (WebSocket(jsg::Lock&, IoContext&, kj::WebSocket&, HibernationPackage)) correctly reads the compat flag, butWebSocket::constructor()andWebSocketPair::constructor()set it after allocation. This is fragile — every new call site must remember to add the override. Consider addingjsg::Lock&to theWebSocket(kj::String url)andWebSocket(kj::Own<kj::WebSocket>)constructors so the default can be set once. -
[LOW] Hibernatable WebSocket message path unaffected — The
sendHibernatableWebSocketMessage()path inglobal-scope.c++:644passeskj::OneOf<kj::String, kj::Array<byte>>directly to thewebSocketMessage()handler (alwaysArrayBuffer). This is by design for the DO handler API, but worth noting thatbinaryTypehas no effect on the hibernatable path. Consider documenting this in the compat flag description or in code comments.
This review was generated by an AI assistant and may contain inaccuracies. Please verify all suggestions independently.
|
I'm Bonk, and I've done a quick review of your PR. Summary: Adds the WHATWG-spec Findings posted to the PR (ranked by severity):
Review posted at: #6178 (review) |
d457314 to
fc08f20
Compare
fc08f20 to
6e2a40a
Compare
6e2a40a to
3e09b4b
Compare
3e09b4b to
81e11ad
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
81e11ad to
0d3eac6
Compare
No description provided.