René's URL Explorer Experiment


Title: [worker_threads]: Main thread receives Error object when the worker throws a primitive value · Issue #35506 · nodejs/node · GitHub

Open Graph Title: [worker_threads]: Main thread receives Error object when the worker throws a primitive value · Issue #35506 · nodejs/node

X Title: [worker_threads]: Main thread receives Error object when the worker throws a primitive value · Issue #35506 · nodejs/node

Description: Version: v14.7.0 Platform: Darwin suin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64 Subsystem: N/A What steps will reproduce the bug? Summary: Since Node v14.7.0, when pr...

Open Graph Description: Version: v14.7.0 Platform: Darwin suin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64 Subsystem: N/A What steps will reproduce the b...

X Description: Version: v14.7.0 Platform: Darwin suin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64 Subsystem: N/A What steps will reproduce the b...

Opengraph URL: https://github.com/nodejs/node/issues/35506

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[worker_threads]: Main thread receives Error object when the worker throws a primitive value","articleBody":"\u003c!--\r\nThank you for reporting an issue.\r\n\r\nThis issue tracker is for bugs and issues found within Node.js core.\r\nIf you require more general support please file an issue on our help\r\nrepo. https://github.com/nodejs/help\r\n\r\n\r\nPlease fill in as much of the template below as you're able.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify affected core module name\r\n-->\r\n\r\n* **Version**: v14.7.0\r\n* **Platform**: Darwin suin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64\r\n* **Subsystem**: N/A\r\n\r\n### What steps will reproduce the bug?\r\n\r\nSummary: Since Node v14.7.0, when primitive values are thrown in a worker, the main thread receives it as Error objects.\r\n\r\nI'm not sure this is actually a bug. But I couldn't find out the information about this breaking change. So I have created this issue. If this is an expected change, please close this issue.\r\n\r\n```js\r\n// main.js\r\nconst { Worker } = require('worker_threads')\r\nconst worker = new Worker('./worker.js')\r\nconsole.log(process.versions.node)\r\nworker.on('error', err => {\r\n  console.error(err)\r\n})\r\n```\r\n\r\n```js\r\n// worker.js\r\nthrow 'Error was thrown in worker'\r\n```\r\n\r\nin Node v14.6.0:\r\n\r\n```\r\n$ node main.js\r\n14.6.0\r\nError was thrown in worker\r\n```\r\n\r\nin Node v14.7.0:\r\n\r\n```\r\n$ node main.js\r\n14.7.0\r\nError [ERR_UNHANDLED_ERROR]: Unhandled error. ('Error was thrown in worker')\r\n    at process.emit (events.js:303:17)\r\n    at emitUnhandledRejectionOrErr (internal/event_target.js:541:11)\r\n    at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:356:9)\r\n    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26) {\r\n  code: 'ERR_UNHANDLED_ERROR',\r\n  context: 'Error was thrown in worker'\r\n}\r\n```\r\n\r\nOther primitives:\r\n\r\n\u003cdetails>\r\n\r\n__Undefined__\r\n\r\n```js\r\n// worker.js\r\nthrow undefined\r\n```\r\n\r\n```\r\n$ node main.js\r\n14.6.0\r\nundefined\r\n\r\n$ node main.js\r\n14.7.0\r\nError [ERR_UNHANDLED_ERROR]: Unhandled error. (undefined)\r\n    at process.emit (events.js:303:17)\r\n    at emitUnhandledRejectionOrErr (internal/event_target.js:541:11)\r\n    at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:356:9)\r\n    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26) {\r\n  code: 'ERR_UNHANDLED_ERROR',\r\n  context: undefined\r\n}\r\n```\r\n\r\n__Number__\r\n\r\n```js\r\n// worker.js\r\nthrow 0\r\n```\r\n\r\n```\r\n$ node main.js\r\n14.6.0\r\n0\r\n\r\n$ node main.js\r\n14.7.0\r\nError [ERR_UNHANDLED_ERROR]: Unhandled error. (0)\r\n    at process.emit (events.js:303:17)\r\n    at emitUnhandledRejectionOrErr (internal/event_target.js:541:11)\r\n    at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:356:9)\r\n    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26) {\r\n  code: 'ERR_UNHANDLED_ERROR',\r\n  context: 0\r\n}\r\n```\r\n\r\n__Symbol__\r\n\r\n```js\r\n// worker.js\r\nthrow Symbol('this is a symbol')\r\n```\r\n\r\n```\r\n$ node main.js\r\n14.6.0\r\nSymbol(this is a symbol)\r\n\r\n$ node main.js\r\n14.7.0\r\nError [ERR_UNHANDLED_ERROR]: Unhandled error. (Symbol(this is a symbol))\r\n    at process.emit (events.js:303:17)\r\n    at emitUnhandledRejectionOrErr (internal/event_target.js:541:11)\r\n    at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:356:9)\r\n    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26)\r\n```\r\n\r\n\u003c/details>\r\n\r\n\r\n\r\n\r\n\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\nThere is no condition.\r\n\r\n### What is the expected behavior?\r\n\r\nI'm not sure which is valid behavior, but at point of view of backward compatibilities, it would be the expected behavior that the main thread receives the unhandled primitive error as the primitive value instead of the Error object like the Node v14.6.0 behavior.\r\n\r\n### What do you see instead?\r\n\r\nThe main thread gets the Error object.\r\n\r\n### Additional information\r\n\r\n\u003c!--\r\nTell us anything else you think we should know.\r\n-->\r\n","author":{"url":"https://github.com/suin","@type":"Person","name":"suin"},"datePublished":"2020-10-05T15:23:18Z","url":"https://github.com/nodejs/node/issues/35506"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7a6d092a-f94a-1d72-48c9-b0a0c7f5c44b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE154:36D84F:9791AC:C9B3AD:6AED30C5
html-safe-nonce8c5401d55c7b8e3ddc9a9ed4c85c9aa332b20ecb1499249f50556456799c7700
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTU0OjM2RDg0Rjo5NzkxQUM6QzlCM0FEOjZBRUQzMEM1IiwidmlzaXRvcl9pZCI6IjI2NjkxMjY3MTIyOTYyODg0NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9cb52145284de70df925f43eed7b24d6e58055ab0a7f745f070a55fa77715772
hovercard-subject-tagissue:714938145
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/35506/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9a7263c615df6368bfe5ed82185ea697191e8abf3bcff40ddd059cf4cd769115/nodejs/node/issues/35506
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9a7263c615df6368bfe5ed82185ea697191e8abf3bcff40ddd059cf4cd769115/nodejs/node/issues/35506
og:image:altVersion: v14.7.0 Platform: Darwin suin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64 Subsystem: N/A What steps will reproduce the b...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesuin
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/35506#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F35506
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F35506
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/35506
Reloadhttps://github.com/nodejs/node/issues/35506
Reloadhttps://github.com/nodejs/node/issues/35506
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/35506
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/35506
#64365https://github.com/nodejs/node/pull/64365
[worker_threads]: Main thread receives Error object when the worker throws a primitive valuehttps://github.com/nodejs/node/issues/35506#top
#64365https://github.com/nodejs/node/pull/64365
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
eventtargetIssues and PRs related to the EventTarget implementation.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22eventtarget%22
workerIssues and PRs related to the worker_threads module and Worker API.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22worker%22
https://github.com/suin
suinhttps://github.com/suin
on Oct 5, 2020https://github.com/nodejs/node/issues/35506#issue-714938145
https://github.com/aduh95
aduh95https://github.com/aduh95
on Oct 5, 2020https://github.com/nodejs/node/issues/35506#issuecomment-703834373
https://github.com/codebytere
codebyterehttps://github.com/codebytere
on Oct 8, 2020https://github.com/nodejs/node/issues/35506#issuecomment-705269708
0aa3809b6bhttps://github.com/nodejs/node/commit/0aa3809b6b
@addaleaxhttps://github.com/addaleax
addaleaxhttps://github.com/addaleax
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
workerIssues and PRs related to the worker_threads module and Worker API.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22worker%22
eventtargetIssues and PRs related to the EventTarget implementation.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22eventtarget%22
on Oct 8, 2020https://github.com/nodejs/node/issues/35506#event-3853068639
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 8, 2020https://github.com/nodejs/node/issues/35506#issuecomment-705272039
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 10, 2020https://github.com/nodejs/node/issues/35506#issuecomment-706622613
@jasnellhttps://github.com/jasnell
@benjamingrhttps://github.com/benjamingr
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 27, 2020https://github.com/nodejs/node/issues/35506#issuecomment-717598088
@jasnellhttps://github.com/jasnell
@benjamingrhttps://github.com/benjamingr
https://github.com/benjamingr
benjamingrhttps://github.com/benjamingr
on Oct 28, 2020https://github.com/nodejs/node/issues/35506#issuecomment-718048348
#2https://github.com/nodejs/node/pull/2
https://github.com/jasnell
jasnellhttps://github.com/jasnell
on Jan 25, 2021https://github.com/nodejs/node/issues/35506#issuecomment-766900591
https://github.com/yashLadha
yashLadhahttps://github.com/yashLadha
on Jan 21, 2022https://github.com/nodejs/node/issues/35506#issuecomment-1018697469
https://github.com/benjamingr
benjamingrhttps://github.com/benjamingr
on Jan 21, 2022https://github.com/nodejs/node/issues/35506#issuecomment-1018766146
@yashLadhahttps://github.com/yashLadha
https://github.com/yashLadha
yashLadhahttps://github.com/yashLadha
on Jan 22, 2022https://github.com/nodejs/node/issues/35506#issuecomment-1019025416
@benjamingrhttps://github.com/benjamingr
https://github.com/benjamingr
benjamingrhttps://github.com/benjamingr
on Jan 22, 2022https://github.com/nodejs/node/issues/35506#issuecomment-1019090094
@yashLadhahttps://github.com/yashLadha
https://github.com/kaydenvanrijn
kaydenvanrijnhttps://github.com/kaydenvanrijn
on Feb 6, 2024https://github.com/nodejs/node/issues/35506#issuecomment-1930904360
@yashLadhahttps://github.com/yashLadha
https://github.com/dobbydobap
dobbydobaphttps://github.com/dobbydobap
on Jul 8, 2026https://github.com/nodejs/node/issues/35506#issuecomment-4916668195
https://github.com/dobbydobap
dobbydobaphttps://github.com/dobbydobap
on Jul 9, 2026https://github.com/nodejs/node/issues/35506#issuecomment-4922255922
#64365https://github.com/nodejs/node/pull/64365
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#64365https://github.com/nodejs/node/pull/64365
on Jul 29, 2026https://github.com/nodejs/node/issues/35506#event-28633687524
nodejs-github-bothttps://github.com/nodejs-github-bot
on Jul 29, 2026https://github.com/nodejs/node/issues/35506#event-28633687601
test: cover worker throwing primitive valueshttps://github.com/nodejs/node/commit/f3b9adbbb8c7b3c4b583c4c47d21235501253c6a
f3b9adbhttps://github.com/nodejs/node/commit/f3b9adbbb8c7b3c4b583c4c47d21235501253c6a
aduh95https://github.com/aduh95
on Aug 3, 2026https://github.com/nodejs/node/issues/35506#event-28901687535
test: cover worker throwing primitive valueshttps://github.com/nodejs/node/commit/cb99338c5a93fe8e73b4f4bb0420ab9bf1198656
cb99338https://github.com/nodejs/node/commit/cb99338c5a93fe8e73b4f4bb0420ab9bf1198656
test: cover worker throwing primitive valueshttps://github.com/nodejs/node/commit/4cb72eecb35d442fae893ff98d304f6444a2d3cf
4cb72eehttps://github.com/nodejs/node/commit/4cb72eecb35d442fae893ff98d304f6444a2d3cf
test: cover worker throwing primitive valueshttps://github.com/nodejs/node/commit/9a139b3c863f1be0cb648871a1c46217c3fcb815
9a139b3https://github.com/nodejs/node/commit/9a139b3c863f1be0cb648871a1c46217c3fcb815
test: cover worker throwing primitive valueshttps://github.com/nodejs/node/commit/539f5dc8f9f3a5697e3af6890039a60fbeb2dde8
539f5dchttps://github.com/nodejs/node/commit/539f5dc8f9f3a5697e3af6890039a60fbeb2dde8
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/35506
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/35506
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
eventtargetIssues and PRs related to the EventTarget implementation.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22eventtarget%22
workerIssues and PRs related to the worker_threads module and Worker API.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22worker%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.