Skip to content
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

Error propagation - Original error lost #1925

Open
xescuder opened this issue Nov 7, 2023 · 4 comments
Open

Error propagation - Original error lost #1925

xescuder opened this issue Nov 7, 2023 · 4 comments

Comments

@xescuder
Copy link

xescuder commented Nov 7, 2023

Using async retry function some errors are wrapped incorrectly. The error thrown is a string with [object Object], so we're losing original error.

This happens for example with some APIs that are throwing an error with error.errorMessages field and not error.message, as expected by current 3.0.5 async release.

@nwalters512
Copy link
Contributor

Can you provide a self-contained reproduction or a failing test? Are your errors passing the instanceof Error check? That is, are they actually errors, or just random objects?

@xescuder
Copy link
Author

xescuder commented Nov 7, 2023

Sorry, but it's a project which I can't share it directly. The error is generated from jira.js and Xray GraphQL API clients. Anyway, I've debugged the code to see that your promise callback is getting the error from these APIs, but the condition is not Error instance and not message field exists. I think the problem is that the asyn callback should bypass directly the err, so it's managed by the code.

@nwalters512
Copy link
Contributor

I'd recommend looking into why that conditional is failing. It's unconventional to throw or reject with a non-Error object; maybe you can update your code or your dependencies to reject with an Error or a subclass of it?

@xescuder
Copy link
Author

xescuder commented Nov 8, 2023

I'm catching these exceptions and wrapping them with an Error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants