Worker Threads: Add transferList to Worker constructor options #32250
Labels
feature request
Issues that request new features to be added to Node.js.
good first issue
Issues that are suitable for first-time contributors.
worker
Issues and PRs related to Worker support.
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 passingtransferList
items such asMessagePort
. Attempts to pass aMessagePort
within the WorkersworkerData
currently 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
transferList
on theWorker
constructor would be helpful in initializing the Worker immediately with aMessagePort
rather than sending theMessagePort
on 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
MessagePort
in a subsequentpostMessage(..., transferList)
. However it doing so involves async initialization of theWorker
which is less desirable than initializing immediately on theWorker
constructor.The text was updated successfully, but these errors were encountered: