Title: Worker Threads: Add transferList to Worker constructor options · Issue #32250 · nodejs/node · GitHub
Open Graph Title: Worker Threads: Add transferList to Worker constructor options · Issue #32250 · nodejs/node
X Title: Worker Threads: Add transferList to Worker constructor options · Issue #32250 · nodejs/node
Description: Is your feature request related to a problem? Please describe. Based on the current documentation listed here, it doesn't seem possible to specify a transferList on the Worker constructor. This prohibits passing transferList items such a...
Open Graph Description: Is your feature request related to a problem? Please describe. Based on the current documentation listed here, it doesn't seem possible to specify a transferList on the Worker constructor. This pro...
X Description: Is your feature request related to a problem? Please describe. Based on the current documentation listed here, it doesn't seem possible to specify a transferList on the Worker constructor. This...
Opengraph URL: https://github.com/nodejs/node/issues/32250
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Worker Threads: Add transferList to Worker constructor options","articleBody":"**Is your feature request related to a problem? Please describe.**\r\n\r\nBased on the current documentation listed [here](https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options), it doesn't seem possible to specify a `transferList` on the Worker constructor. This prohibits passing `transferList` items such as `MessagePort`. Attempts to pass a `MessagePort` within the Workers `workerData` currently results in the following error.\r\n```\r\nTypeError: MessagePort was found in message but not listed in transferList\r\n```\r\n**Describe the solution you'd like**\r\n\r\nGiven the current error, and if its technically feasible to do so...being able to supply a `transferList` on the `Worker` constructor would be helpful in initializing the Worker immediately with a `MessagePort` rather than sending the `MessagePort` on a subsequent `postMessage(...)`. Perhaps something like the following could be allowed.\r\n\r\n```javascript\r\nconst channel = new MessageChannel()\r\nconst workerData = { port: channel.port1 }\r\nconst transferList = [channel.port1]\r\nconst worker = new Worker('./worker.js', { workerData, transferList })\r\n```\r\n\r\n\r\n**Describe alternatives you've considered**\r\n\r\nIt is entirely possible to work around this by sending a `MessagePort` in a subsequent `postMessage(..., transferList)`. However it doing so involves async initialization of the `Worker` which is less desirable than initializing immediately on the `Worker` constructor.\r\n","author":{"url":"https://github.com/sinclairzx81","@type":"Person","name":"sinclairzx81"},"datePublished":"2020-03-13T15:34:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/32250/node/issues/32250"}
| 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:fad5a9ca-a3ea-d2bb-fa35-c2eba7e10d78 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C7C0:776B8:D6D2E6:13A32AD:6A4E2DB5 |
| html-safe-nonce | 970a23d39fa308dd2e7b163d85f265d76c4c1e9c7890498c98bc80eca12bd962 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0MwOjc3NkI4OkQ2RDJFNjoxM0EzMkFEOjZBNEUyREI1IiwidmlzaXRvcl9pZCI6IjM5Mzc1MjA4OTQwMDg0Nzc5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9c450ffb2e1a45c2cf8fcf57596f4b425a4874e867ebd2ddba4437ce271ac5a7 |
| hovercard-subject-tag | issue:580680104 |
| 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/32250/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0c83600fec67eb2801373f28aca9a0c0757dc64792175bf9b8ba6e201ec741ba/nodejs/node/issues/32250 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0c83600fec67eb2801373f28aca9a0c0757dc64792175bf9b8ba6e201ec741ba/nodejs/node/issues/32250 |
| og:image:alt | Is your feature request related to a problem? Please describe. Based on the current documentation listed here, it doesn't seem possible to specify a transferList on the Worker constructor. This pro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sinclairzx81 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| 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 | d9dd20d38f8ae3c4cb6b597807431db300d0bd2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width