-
Notifications
You must be signed in to change notification settings - Fork 25
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
Custom error objects aren't cloneable #29
Comments
Is this actionable for this module? How could we improve things? |
It's likely more something just to document just in case. If you're not using custom errors at all then things should Just Work, but if any part of this is relying on things like a |
I would not think so, anyway let's keep this open and we'll see if it becomes a problem. |
you could provide an API for registering custom error constructors in the worker thread, then you'd have to somehow communicate that an error object that has entered the worker thread should be "recast" (Object.setPrototypeOf(CustomError.call(err), CustomError.prototype) ? ) |
Just something to remember... in https://github.com/pinojs/thread-stream/blob/main/lib/worker.js, when the destination error event is emitted, an 'ERROR' message is posted back to the origin thread...
https://github.com/pinojs/thread-stream/blob/main/lib/worker.js#L21-L26:
Error
objects can be a bit odd in the structured clone algorithm. Iferr
is a custom error object (e.g. something like Node.jsDOMException
or something likeclass MyError extends Error
, what comes out on the other side will not match exactly. It will certainly clone as anError
, but you'll lose the custom extension on it.The text was updated successfully, but these errors were encountered: