-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: unclear conditions under which Worker's 'messageerror' is emmited #36333
Comments
To be clear, I'm happy to update the docs and provide a PR. Just lacking enough knowledge on the internal c++ workings of workers. |
@nodejs/workers |
pinging @addaleax (whom I believe has the most context / understanding of this part of the code) |
Look at parallel/test-crypto-key-objects-messageport.js and test/parallel/test-worker-message-port-transfer-filehandle.js |
Yeah, that’s a fair point. Part of why this was was left appear unclear is that it is also unclear (to me) in the HTML spec when this event would be emitted in the browser implementations. Currently, this event is emitted when there is an error occuring while instantiating the posted JS object on the receiving end, where there would otherwise be no way to communicate that situation. The examples pointed to by @benjamingr are for situations in which Node.js API objects (not JS built-ins) are received in a You could probably make some of the deserialization methods throw an exception in some way, and generate the event through that, for example by messing with the prototypes of Node.js API objects, but ultimately, I don’t think there’s any good way to generate these events through the public API currently. I can’t think of any reason why deserializing a message should fail once it has been posted, except for limitations in Node.js’ builtins, so, for testing, I would currently recommend just to emit the events directly. |
Adapting addaleax's explanation from the issue. Fixes: nodejs#36333 Signed-off-by: James M Snell <jasnell@gmail.com>
Location
Section of the site where the content exists
Affected URL(s):
Description
Concise explanation of the problem
It is unclear from the documentation how one could cause/simulate
messageerror
to be emitted by the Worker. It would be useful to understand the conditions when it happens and also be able to simulate such situations when testing code. A concrete example when this would be helpful is in bree codebase, where test coverage has been skipped because there's no way to simulate this event.submit a pull request.
The text was updated successfully, but these errors were encountered: