Give WebSocket onopen, onmessage, onclose and onerror attributes #8851
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 230 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.326
Real PR Conversation Timeline
1 comments
"Review active on #8851"
general
weight: 0.35
jasnell
WebSocket had no
on<type>accessors.ws.onmessage = fnonly worked because EventTarget dispatch reads a plainon<type>property and runs it before every listener. Sows.onopenreadundefinedinstead ofnull,ws.onopen = 2kept the 2, and the four cases in websockets/eventhandlers.any.js plus the idlharnessonattribute cases failed.In this patch WebSocket gets the four attributes on its prototype, backed by
EventTarget::setEventHandlerAttribute()the same wayAbortSignal.onabortis. A non-object reads back asnull, and a non-callable object is kept but never called. The handler runs from its own position in the listener list. The first commit only names the handler value type on EventTarget so both classes can share it.No compat flag. MessagePort.onmessage and EventSource.on made the same move without one. Here is what a Worker can see change:
nullbefore anything is assignednull; it was never called before eitheron<type>andaddEventListener()are both used for one type, the handler runs in registration order instead of firstObject.keys(), anddelete ws.onmessageno longer removes the handlerutil.inspect()of a WebSocket lists the four attributesthisinside a handler doesn't change. An ownon<type>property defined without the setter, such as a class field on a subclass, still goes through the legacy lookup.The new websocket-handlers-test covers defaults, primitives, non-callable objects, handler position and close. Its defaults, primitives and position cases fail without the change. The 4 eventhandlers.any.js and 8 idlharness expected failures are removed, and the websocket, events, abort, http and dom/events tests pass.