← Back to Pull requests

events: keep event in dispatching state across all listeners #67765

Open
unknown opened this pull request with 185 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 24, 2026 23:16 UTC
Author

EventTarget.prototype[kHybridDispatch] sets event[kIsBeingDispatched] = true before the listener loop and clears it after the loop finishes, but it also cleared arg[kIsBeingDispatched] = false inside the loop right after invoking each listener.

As a result, only the first listener saw the event as being dispatched. Any second or later listener observed event.currentTarget === null, event.eventPhase === Event.NONE (0), an empty event.composedPath(), and could mutate the event with initEvent() or re-dispatch it without ERR_EVENT_RECURSION:

const et = new EventTarget();
et.addEventListener('foo', (e) => console.log('L1:', e.currentTarget === et, e.eventPhase, e.composedPath().length));
et.addEventListener('foo', (e) => console.log('L2:', e.currentTarget === et, e.eventPhase, e.composedPath().length));
et.dispatchEvent(new Event('foo'));

// Before:
// L1: true 2 1
// L2: false 0 0

// After:
// L1: true 2 1
// L2: true 2 1

This removes the premature reset inside the loop and wraps the loop in try/finally so kIsBeingDispatched is always cleared when dispatch exits, even if a once-listener removal hook ([kRemoveListener]) throws.

Note (semver-major): re-dispatching the same event synchronously or calling initEvent() from a second or later listener now throws ERR_EVENT_RECURSION or is ignored, respectively, matching the first listener and the WHATWG DOM spec.

Refs: https://dom.spec.whatwg.org/#concept-event-dispatch

Diff: 185 lines (+138 / -47) across 2 files Reviewer: gurgunday Review duration: 8230m
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.36) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 185 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.313
Real PR Conversation Timeline
1 comments
"Review active on #67765"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 43.0% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 35.7% (MEDIUM) · Higher = larger blast radius
35.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 43.0% · Lower = rushed or shallow review
43.0%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 20.4% · Safe to merge
20.4%
Repository