You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a Promise boundary bundled by some bundlers #806
Custom error subclasses (e.g. EscrowError extends TrustFlowError) can fail instanceof checks after passing through certain bundler/transpilation configurations (notably targeting older JS targets) that don't correctly handle extending built-in Error.
Component
core
Steps to Reproduce
Build a consuming app targeting an older JS target (e.g. ES5) using a bundler known to have this issue with native class extension.
Catch a EscrowError thrown by the SDK.
Check error instanceof EscrowError and error instanceof TrustFlowError.
Expected Behavior
Custom error classes should reliably support instanceof checks regardless of the consuming app's build target, typically by following the documented workaround pattern for extending Error in TypeScript/Babel.
Actual Behavior
instanceof checks unexpectedly return false for errors that genuinely are instances of the expected class, breaking any error-type-based handling logic in the consuming app.
Environment
SDK version: 0.3.x
Node version: 20.x, 22.x
OS: macOS / Linux
Network: TESTNET
Code Example
try{awaitcreateEscrow(client,badParams);}catch(e){if(einstanceofEscrowError){/* never reached in some build configs */}}
Error Output
N/A — no thrown error; behavior is incorrect but silent.
Difficulty
🟡 Medium
Additional Context
The error classes extend Error without the Object.setPrototypeOf workaround needed for compatibility with ES5-targeting transpilation.
I am interested in taking up "[BUG] errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a Promise boundary bundled by some bundlers" and implementing a production-grade solution.
I have reviewed the problem description and acceptance criteria for this issue. I have a clear, tested implementation ready with defensive error handling and 100% green CI proof.
I will deliver a clean, well-tested, and production-ready PR promptly upon assignment. Kindly assign this issue to me.
I reviewed the requirements for errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a Promise boundary bundled by some bundlers. Looking into the issue, we need to resolve 'errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a Promise boundary bundled by some bundlers' cleanly across the target modules. My plan is to trace the current code execution path in errors.ts to isolate the behavior boundary, implement a focused, modular fix for 'errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a promise boundary bundled by some bundlers' adhering strictly to repository architecture, and ensure ensure defensive guards and backward compatibility are maintained.
For testing, I'll reproduce the target scenario locally, add regression unit tests, and confirm all CI checks pass 100% green.
Happy to take this on. Please assign it over and I'll get the PR ready.
Activity
ranjeet150 commentedon Oct 29, 2026
Hello,
I am interested in taking up "[BUG] errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a Promise boundary bundled by some bundlers" and implementing a production-grade solution.
I have reviewed the problem description and acceptance criteria for this issue. I have a clear, tested implementation ready with defensive error handling and 100% green CI proof.
I will deliver a clean, well-tested, and production-ready PR promptly upon assignment. Kindly assign this issue to me.
Thank you!
ranjan1969x commentedon Nov 8, 2026
Hi everyone,
I reviewed the requirements for errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a Promise boundary bundled by some bundlers. Looking into the issue, we need to resolve 'errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a Promise boundary bundled by some bundlers' cleanly across the target modules. My plan is to trace the current code execution path in
errors.tsto isolate the behavior boundary, implement a focused, modular fix for 'errors.ts error class hierarchy doesn't preserve the instanceof relationship after being caught across a promise boundary bundled by some bundlers' adhering strictly to repository architecture, and ensure ensure defensive guards and backward compatibility are maintained.For testing, I'll reproduce the target scenario locally, add regression unit tests, and confirm all CI checks pass 100% green.
Happy to take this on. Please assign it over and I'll get the PR ready.