question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors are not caught automatically from `fetch()`

See original GitHub issue

Version

@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

  1. Create a page component
  2. Throw a new Error('...') in both data and fetch
  3. Visit the page and observe that the error from data is reported, while the error from fetch 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:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pi0commented, Feb 7, 2021

@rchl It is possible to use vue $emit/$on. We would only need some internal changes to allow plugins using $on. Made #8786 to track

1reaction
rchlcommented, Feb 7, 2021

Just checked and yes, errors from fetch() are not caught. Nuxt catches those itself and exposes on this.$fetchState.error so Sentry would have to have some extra logic to capture those.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found