-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
worker: add support for platformData #37486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
lgtm with the global issue solved. Corey's proposed solution seems workable but still kind of unfortunate. |
|
Would it make sense to implement this as experimental so we have some flexibility to tinker for the first few patch/minor releases? |
|
We could get by with making platformData a Map to achieve the result. And yes, experimental is fine too start. |
|
Since this works a lot like |
My only concern there would be developers mistaking it for environment variables. Hmm... perhaps |
|
@coreyfarrell @addaleax @Trott @devsnek .. updated! Please take another look |
coreyfarrell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, I think it will work for nyc once combined with the ability to inject code to run before the workers main script.
a4ded12 to
ebb9628
Compare
ebb9628 to
b40c8f7
Compare
These APIs allow arbitrary, cloneable JavaScript values to be set and passed to all new Worker instances spawned from the current context. It is similar to `workerData` except that environment data is set independently of the `new Worker()` constructor, and the the value is passed automatically to all new Workers. This is a *partial* fix of nodejs#30992 but does not implement a complete fix. Signed-off-by: James M Snell <[email protected]>
b40c8f7 to
4f3f0f4
Compare
|
@addaleax @coreyfarrell @gireeshpunathil ... alrighty! Updated! Please take a look. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Landed in 802b3e7 |
The
worker.platformDataandworker.setPlatformData()APIs allow an arbitrary, cloneable JavaScript value to be set and passed to all new Worker instances spawned from the current context. It is similar toworkerDataexcept thatplatformDatais set independently of thenew Worker()constructor, and the value is passed automatically to all new Workers.This is a partial fix of #30992
but does not implement a complete fix.
Signed-off-by: James M Snell [email protected]
/cc @addaleax @coreyfarrell