Errors are not caught automatically from `fetch()`
See original GitHub issueVersion
@nuxtjs/sentry: 4.3.5 nuxt: 2.14.6
Sentry configuration
The default, client and server enabled
Reproduction Link
Not sure how to provide a reproducible example. I’ll just describe the steps to reproduce, it’s pretty straight-forward:
Steps to reproduce
- Create a page component
- Throw a
new Error('...')
in bothdata
andfetch
- Visit the page and observe that the error from
data
is reported, while the error fromfetch
isn’t
What is Expected? What is actually happening?
The error from fetch
should be reported automatically. It’s not.
I realize there’s a section on asyncData
in the readme, but I’m not sure if it is also meant to be about the fetch
method. Seems like maybe the readme is not up to date, because one can just use the new fetch instead of asyncData
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Handling Failed HTTP Responses With fetch() - TJ VanToll
Per MDN, the fetch() API only rejects a promise when a “network error is encountered, although this usually means permissions issues or ...
Read more >When That's Not So Fetch: Error Handling With fetch()
When errors are encountered during a fetch() call, it is often necessary to halt the compiler from reading the next few lines of...
Read more >Fetch: reject promise and catch the error if status is not OK?
Fetch promises only reject with a TypeError when a network error occurs. Since 4xx and 5xx responses aren't network errors, there's nothing ...
Read more >Fetch - Error Handling for Failed HTTP Responses and ...
The fetch() function will automatically throw an error for network errors but not for HTTP errors such as 4xx or 5xx responses.
Read more >Implement error handling when using the Fetch API - web.dev
When the Fetch API throws errors #. This example uses a try / catch block statement to catch any errors thrown within the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rchl It is possible to use vue
$emit
/$on
. We would only need some internal changes to allow plugins using$on
. Made #8786 to trackJust checked and yes, errors from
fetch()
are not caught. Nuxt catches those itself and exposes onthis.$fetchState.error
so Sentry would have to have some extra logic to capture those.