-
Notifications
You must be signed in to change notification settings - Fork 938
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
Yup error is no more an error #2111
Comments
This has caused my team problems too, eslint is not happy about us trying to throw something that isn't an Error @tedeschia I believe this is related to your PR #2072 |
eslint can’t know whether it’s actually instanceof error, though, since that’s not statically analyzeable. |
Oops, this is a mistake didn't realize this was switched to an |
It was switched to implements to avoid capturing stack trace on every error, which was causing performance issues on large arrays with thousands of new Error objects. |
That seems like a breaking change since stack traces are a pretty important feature, and they need to be captured at error creation time. Why would anyone have an array with thousands of errors? |
@ljharb I'm not sure what would be the use of the stack trace captured on a validation process. |
Seems like that behavior could be controlled by an option, so that by default it remains an Error for the common case? |
@ljharb It causes a @typescript-eslint/no-throw-literal error |
@tedeschia not sure if you are looking for How we use it to limit the stack trace: |
We can revisit the perf improvement approach, but in the meantime i've reverted that part of the change and pushed @tedeschia happy to work the perf improvement back in we just need to find a backwards compatible way to do it. sorry for the churn here folks |
Appreciate the work @jquense and @tedeschia, thanks for the quick responses :) |
Describe the bug
Yup
err instanceof Error
returns falseTo Reproduce
Install with:
The following code prints:
Expected behavior
As in v1.1.1
err instanceof Error
should return truePlatform (please complete the following information):
Node.js 18.x and 20.x
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: