-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
worker: add ability to unshift message from MessagePort #27294
Conversation
Ping @nodejs/workers |
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.
The actual code LGTM the two concerns I have is:
- Wouldn't it be better to provide an API that makes the ports AsyncIterable instead of adding this?
- Are we OK adding this given there is no equivalent?
Actual code LGTM and if you find it useful I'm good with it.
@benjamingr I think that async interation is of limited usefulness for APIs that refer to external events, like messages from another thread… but I wouldn’t mind making
You mean, no browser equivalent? I’m personally okay with that, yes – if we don’t want this, that’s okay, but I’d still prefer to make some way of transferring arbitrary data synchronously possible. |
d4e82e4
to
248a203
Compare
Got around to fixing CI for this, had to revert a bit of the last commit. |
Still lgtm |
In combination with Atomics, this makes it possible to implement generic synchronous functionality, e.g. `importScript()`, in Workers purely by communicating with other threads. This is a continuation of nodejs#26686, where a preference for a solution was voiced that allowed reading individual messages, rather than emitting all messages through events.
248a203
to
8bd751a
Compare
Landed in 76f2168 |
In combination with Atomics, this makes it possible to implement generic synchronous functionality, e.g. `importScript()`, in Workers purely by communicating with other threads. This is a continuation of #26686, where a preference for a solution was voiced that allowed reading individual messages, rather than emitting all messages through events. PR-URL: #27294 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
In combination with Atomics, this makes it possible to implement generic synchronous functionality, e.g. `importScript()`, in Workers purely by communicating with other threads. This is a continuation of #26686, where a preference for a solution was voiced that allowed reading individual messages, rather than emitting all messages through events. PR-URL: #27294 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Notable changes: * process: * Log errors using `util.inspect` in case of fatal exceptions (Ruben Bridgewater) #27243 * repl: * Add `process.on('uncaughtException')` support (Ruben Bridgewater) #27151 * stream: * Implemented `Readable.from` async iterator utility (Guy Bedford) #27660 * tls: * Expose built-in root certificates (Ben Noordhuis) #26415 * Support `net.Server` options (Luigi Pinca) #27665 * Expose `keylog` event on TLSSocket (Alba Mendez) #27654 * worker: * Added the ability to unshift messages from the `MessagePort` (Anna Henningsen) #27294
Notable changes: * esm: * Added the `--experimental-wasm-modules` flag to support WebAssembly modules (Myles Borins & Guy Bedford) #27659 * process: * Log errors using `util.inspect` in case of fatal exceptions (Ruben Bridgewater) #27243 * repl: * Add `process.on('uncaughtException')` support (Ruben Bridgewater) #27151 * stream: * Implemented `Readable.from` async iterator utility (Guy Bedford) #27660 * tls: * Expose built-in root certificates (Ben Noordhuis) #26415 * Support `net.Server` options (Luigi Pinca) #27665 * Expose `keylog` event on TLSSocket (Alba Mendez) #27654 * worker: * Added the ability to unshift messages from the `MessagePort` (Anna Henningsen) #27294 PR-URL: #27799
Notable changes: * esm: * Added the `--experimental-wasm-modules` flag to support WebAssembly modules (Myles Borins & Guy Bedford) #27659 * process: * Log errors using `util.inspect` in case of fatal exceptions (Ruben Bridgewater) #27243 * repl: * Add `process.on('uncaughtException')` support (Ruben Bridgewater) #27151 * stream: * Implemented `Readable.from` async iterator utility (Guy Bedford) #27660 * tls: * Expose built-in root certificates (Ben Noordhuis) #26415 * Support `net.Server` options (Luigi Pinca) #27665 * Expose `keylog` event on TLSSocket (Alba Mendez) #27654 * worker: * Added the ability to unshift messages from the `MessagePort` (Anna Henningsen) #27294 PR-URL: #27799
worker: move(landed as part of #27705)receiving_messages_
field toMessagePort
This is a property of the native object associated with the
MessagePort
, not something that should be set on theconceptual
MessagePort
that may be transferred around.(This is just cleanup that’s not directly related to the next commit exceptfor merge conflicts.)
worker: add ability to unshift message from MessagePort
In combination with Atomics, this makes it possible to implement
generic synchronous functionality, e.g.
importScript()
, in Workerspurely by communicating with other threads.
This is a continuation of #26686,
where a preference for a solution was voiced that allowed reading
individual messages, rather than emitting all messages through events.
(/cc @devsnek, @BridgeAR, @nodejs/workers)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes