Title: worker: `messageerror` listeners remain during `exit` · Issue #65782 · nodejs/node · GitHub
Open Graph Title: worker: `messageerror` listeners remain during `exit` · Issue #65782 · nodejs/node
X Title: worker: `messageerror` listeners remain during `exit` · Issue #65782 · nodejs/node
Description: Version v24.14.1 The typo is also present in the v26.8.1 source and in the current main branch. Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem worker_threads What steps will reproduce the bug? Run the following without any thir...
Open Graph Description: Version v24.14.1 The typo is also present in the v26.8.1 source and in the current main branch. Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem worker_threads What steps will reproduce the...
X Description: Version v24.14.1 The typo is also present in the v26.8.1 source and in the current main branch. Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem worker_threads What steps will reproduce the...
Opengraph URL: https://github.com/nodejs/node/issues/65782
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"worker: `messageerror` listeners remain during `exit`","articleBody":"## Version\n\nv24.14.1\n\nThe typo is also present in the v26.8.1 source and \nin the current `main` branch.\n\n## Platform\n\n```text\nMicrosoft Windows NT 10.0.26200.0 x64\n```\n\n## Subsystem\n\nworker_threads\n\n## What steps will reproduce the bug?\n\nRun the following without any third-party dependencies:\n\n```js\nconst { Worker } = require('node:worker_threads');\n\nconst worker = new Worker('', { eval: true });\nconst listener = () => {};\n\nworker.on('message', listener);\nworker.on('messageerror', listener);\n\nworker.on('exit', () => {\n console.log({\n message: worker.listenerCount('message'),\n messageerror: worker.listenerCount('messageerror'),\n });\n});\n```\n\n## How often does it reproduce? Is there a required condition?\n\nIt reproduces every time on v24.14.1 and on the current `main` branch at\n`7177c14789a7376866dfe6c04f5cd4da489cfbe6`. It occurs both when a worker exits\nnormally and when it is stopped with `worker.terminate()`.\n\n## What is the expected behavior? Why is that the expected behavior?\n\nBoth messaging listener counts should be zero while the `exit` listener is\nrunning:\n\n```text\n{ message: 0, messageerror: 0 }\n```\n\nThe worker exit cleanup explicitly removes the `message` listeners before\nemitting `exit` and appears intended to do the same for `messageerror`.\n\n## What do you see instead?\n\nThe `message` listener is removed, but the `messageerror` listener is still\npresent:\n\n```text\n{ message: 0, messageerror: 1 }\n```\n\n## Additional information\n\nThe targeted cleanup currently calls\n`removeAllListeners('messageerrors')`, but the event name is `messageerror`:\n\nhttps://github.com/nodejs/node/blob/7177c14789a7376866dfe6c04f5cd4da489cfbe6/lib/internal/worker.js#L395-L396\n\nThe typo was introduced in commit `5968c5423530aeaa10c02eae3e8423c6514cdd1a`:\n\nhttps://github.com/nodejs/node/commit/5968c5423530aeaa10c02eae3e8423c6514cdd1a\n\nThere is a later generic `removeAllListeners()` call after the `exit` event is\nemitted, so this report does not claim a persistent listener leak. The observed\nproblem is that the targeted pre-`exit` cleanup does not remove `messageerror`\nlisteners as intended.\n","author":{"url":"https://github.com/kiliczsh","@type":"Person","name":"kiliczsh"},"datePublished":"2026-09-04T09:49:08Z","url":"https://github.com/nodejs/node/issues/65782"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ce0049a6-a180-14b1-2033-1743f5d7abea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D38A:143C91:8321D:B1B8E:6AED047E |
| html-safe-nonce | a8abefa600c596b5827d547a3ae3e6526048db5d11d9df8f7e4fb42cf1cb9879 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzhBOjE0M0M5MTo4MzIxRDpCMUI4RTo2QUVEMDQ3RSIsInZpc2l0b3JfaWQiOiIzOTcwMzg1MDgyOTUzMDQxMDIyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a681af183a09ec24f3525693507476547996d6b70ee677a9183d30bb88621895 |
| hovercard-subject-tag | issue:5346644852 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/65782/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9fa367aa0e010c0dcde7bf9d7cad1e5e48f3f6cc0ac7b7ccae4133457753f33c/nodejs/node/issues/65782 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9fa367aa0e010c0dcde7bf9d7cad1e5e48f3f6cc0ac7b7ccae4133457753f33c/nodejs/node/issues/65782 |
| og:image:alt | Version v24.14.1 The typo is also present in the v26.8.1 source and in the current main branch. Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem worker_threads What steps will reproduce the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kiliczsh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 21e10c535436b2122cfb44c76dfb4af296e371850fb60de16776f8a64e5c3ed8 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 302a6d707c3288a5f951258a2fa3e926b8c8f8cf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width