Stop dispatching parent messages to self.onmessage in node:worker_threads workers #29215
+813
−10
Claude / Claude Code Review
completed
Apr 12, 2026 in 36m 21s
Code review found 1 important issue
Found 3 candidates, confirmed 2. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 1 |
| 🟡 Nit | 0 |
| 🟣 Pre-existing | 0 |
| Severity | File:Line | Issue |
|---|---|---|
| 🔴 Important | src/js/node/worker_threads.ts:458-461 |
Stale wrappedListener slot in removeListener leaks messageListenerCount after on→off→addEventListener |
Annotations
Check failure on line 461 in src/js/node/worker_threads.ts
claude / Claude Code Review
Stale wrappedListener slot in removeListener leaks messageListenerCount after on→off→addEventListener
Aliasing `fake.removeListener` to `MessagePort.prototype.off` (lines 458-461) introduces a regression: when a listener is registered via `parentPort.addEventListener('message', fn)` after previously going through an `on`→`off` cycle, a subsequent `parentPort.removeListener('message', fn)` silently fails because `.off` resolves the stale `fn[wrappedListener]` slot (never cleared by `off`), finds no matching entry in `trackedByListener`, and returns early without calling `releaseListener()`; `mess
Loading