-
Notifications
You must be signed in to change notification settings - Fork 1
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
check before running captureStackTrace #4
Conversation
if (Error.captureStackTrace) | ||
Error.captureStackTrace(this, this.constructor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move to using the raw Error.stack
instead of captureStackTrace
(which is more V8 specific and not widely supported)
if (Error.captureStackTrace) | |
Error.captureStackTrace(this, this.constructor); | |
if (Error().stack) | |
this.stack = Error().stack; |
captureStackTrace
doesn't seem to do more than setting the .stack
variable ourselves. It does support hiding some calls from the stack trace (anything from this.constructor
in our case). Moving to the raw .stack
call seems like a decent solution to get a wider supported stack trace.
https://nodejs.org/api/errors.html#errors_error_capturestacktrace_targetobject_constructoropt
Thoughts?
The purpose of this change is to fix error resolution in the frontend. We're aware that because Although this is a |
I was having a look at the docs and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack seems to be non-standard too, which makes me wonder about just using a polyfill like https://www.npmjs.com/package/error-polyfill |
It says non-standard but seems to have extremely good support? Why don't we continue with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the Error.stack
support is rather wonky. We also don't really need the stack for the kind of errors we throw with this package on the web.
I would rather we just used the |
Stack seems to be already there by default it's not serialisable, adding it manually with |
This little lib is used by both node and frontend, and because some browser might not implement captureStackTrace, it will throw an exception, badly.
This PR is meant to safe check / fix this call and make it safe for the web 馃暦馃暩馃憣