Custom error objects aren't cloneable
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 261
- Forks
- 31
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 4
Description
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:
destination.on('error', function (err) {
parentPort.postMessage({
code: 'ERROR',
err
})
})
Error objects can be a bit odd in the structured clone algorithm. If err is a custom error object (e.g. something like Node.js DOMException or something like class MyError extends Error, what comes out on the other side will not match exactly. It will certainly clone as an Error, but you'll lose the custom extension on it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading lib/worker.js around lines 21-26 and tracing how the ERROR message is received on the origin thread. Check the existing worker error-handling path and determine what behavior is expected for custom Error objects; done means that behavior is preserved across the thread boundary and covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100