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

TypeError: Error.captureStackTrace is not function #26

Closed
matthewpull opened this issue Nov 9, 2021 · 1 comment · Fixed by #27
Closed

TypeError: Error.captureStackTrace is not function #26

matthewpull opened this issue Nov 9, 2021 · 1 comment · Fixed by #27

Comments

@matthewpull
Copy link
Contributor

In fetch.ts on line 64 (https://github.com/unjs/ohmyfetch/blob/main/src/fetch.ts#L64), called when an error occurs during the fetch, a call is made to Error.captureStackTrace. This is a non-standard, V8-specific function that appears to work in Chrome and Nodejs, but does not work in Firefox.

This means that all error-handling is broken when using the Firefox browser, as my user code can no longer receive a FetchError if an issue occurs, but always receives this TypeError (without any of the information, such as response body).

Essentially, this makes ohmyfetch unusable in production code that supports the Firefox browser, or any non-Chromium-based browser.

I would also note that other projects have dealt with this issue by using Error().stack in some fashion - here is an example from 2015: trentm/node-bunyan#224

Please can this issue be resolved as a priority as, again, in its current form this otherwise helpful library cannot be used in general production scenarios.

@matthewpull
Copy link
Contributor Author

Having looked at a few other libraries (including TailwindCSS and HeadlessUI), it seems that this is often fixed by wrapping the call to Error.captureStackTrace in an existence-check. I've created a PR with this change, that should cause no conflicts (only a single line is changed).

@pi0 pi0 closed this as completed in #27 Nov 10, 2021
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

Successfully merging a pull request may close this issue.

1 participant