Fix worker runner cleanup - #6680
Conversation
🦋 Changeset detectedLatest commit: b9edc67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughWorker runner implementations now emit browser disconnect notifications and correctly remove message error listeners. Node workers add scoped cleanup for message, messageerror, and error handlers. Browser tests cover listener removal and disconnect events, with patch changesets added for the affected packages. ChangesWorker runner lifecycle updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Comment |
Bundle Size Analysis
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/platform-node/src/NodeWorkerRunner.ts (1)
77-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression tests for Bun/Node listener cleanup, mirroring the new Browser tests.
This PR adds regression coverage only for
BrowserWorkerRunner(listener removal + disconnect emission). The equivalent fixes in Bun and Node — arguably the more complex change given Node's new scoped multi-listener finalizer — ship without any test verifying listeners are actually detached on scope close.
packages/platform-node/src/NodeWorkerRunner.ts#L77-L116: add a test assertingmessage,messageerror, anderrorlisteners registered onWorkerThreads.parentPort/processare removed when the run scope finalizes (mirroring the Browser "removes the registered messageerror listener" test).packages/platform-bun/src/BunWorkerRunner.ts#L69-L84: add a test asserting themessageerrorlistener added viaonMessageErroris removed with the same reference on scope finalization.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/platform-node/src/NodeWorkerRunner.ts` around lines 77 - 116, Add regression tests for both listener-cleanup implementations: in packages/platform-node/src/NodeWorkerRunner.ts:77-116, verify the run scope removes the registered message, messageerror, and error listeners from WorkerThreads.parentPort/process on finalization; in packages/platform-bun/src/BunWorkerRunner.ts:69-84, verify the messageerror listener registered through onMessageError is removed using the same function reference during scope finalization. Mirror the existing BrowserWorkerRunner cleanup tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/platform-node/src/NodeWorkerRunner.ts`:
- Around line 77-116: Add regression tests for both listener-cleanup
implementations: in packages/platform-node/src/NodeWorkerRunner.ts:77-116,
verify the run scope removes the registered message, messageerror, and error
listeners from WorkerThreads.parentPort/process on finalization; in
packages/platform-bun/src/BunWorkerRunner.ts:69-84, verify the messageerror
listener registered through onMessageError is removed using the same function
reference during scope finalization. Mirror the existing BrowserWorkerRunner
cleanup tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b720d262-bed7-428b-abb0-67f792d27f03
📒 Files selected for processing (5)
.changeset/fix-worker-runner-cleanup.mdpackages/platform-browser/src/BrowserWorkerRunner.tspackages/platform-browser/test/BrowserWorkerRunner.test.tspackages/platform-bun/src/BunWorkerRunner.tspackages/platform-node/src/NodeWorkerRunner.ts
Summary
Testing
Closes EFF-158
Summary by CodeRabbit
Bug Fixes
Tests