-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
Worker Threads: Add transferList to Worker constructor options #32250
Copy link
Copy link
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.workerIssues and PRs related to Worker support.Issues and PRs related to Worker support.
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.workerIssues and PRs related to Worker support.Issues and PRs related to Worker support.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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
transferListon the Worker constructor. This prohibits passingtransferListitems such asMessagePort. Attempts to pass aMessagePortwithin the WorkersworkerDatacurrently results in the following error.Describe the solution you'd like
Given the current error, and if its technically feasible to do so...being able to supply a
transferListon theWorkerconstructor would be helpful in initializing the Worker immediately with aMessagePortrather than sending theMessagePorton a subsequentpostMessage(...). Perhaps something like the following could be allowed.Describe alternatives you've considered
It is entirely possible to work around this by sending a
MessagePortin a subsequentpostMessage(..., transferList). However it doing so involves async initialization of theWorkerwhich is less desirable than initializing immediately on theWorkerconstructor.