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.

Error raised if someone goes offline and attempts a request

See original GitHub issue

Hi! I’m running into an issue where, if someone attempts a request while they are offline, result.headers on line 40 blows up because err.response is undefined. I’m unsure of the proper way to go about fixing this, or if there is something I should be doing with the axios instance before passing it to axios-fetch to avoid this issue altogether.

Any help would be greatly appreciated!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mdlavincommented, Apr 7, 2021

The simplest thing I can think of that might work is to change:

} catch (err) {
  result = err.response;
}

into

} catch (err) {
  // Non-HTTP failures should be re-thrown. This will handle lower level network failures
  if (!err.response) throw err;
  // HTTP level failures can be translated into fetch style responses
  result = err.response;
}

Is it possible for you to try a change like that and see if it fixes your problem?

0reactions
jkdowdlecommented, Jul 15, 2021

Unless someone feels otherwise going to go ahead and close this issue. The proposed solution was implemented in https://github.com/lifeomic/axios-fetch/pull/78 and released in @lifeomic/axios-fetch@2.0.2 https://github.com/lifeomic/axios-fetch/pull/79

Read more comments on GitHub >

github_iconTop Results From Across the Web

$http error handling: distinguishing user offline from other errors
So considering all of above, I have solved the problem using an offline directive which I am using to block user interaction if...
Read more >
A Complete Guide and List of HTTP Status Codes
A complete list of HTTP status codes with explaination of what they are, why they occur and what you can do to fix...
Read more >
What to do when you're booted offline while gaming
Getting “booted” is a common term for someone kicking you off an online game by attacking your internet connection.
Read more >
Handling Failed HTTP Responses With fetch() - TJ VanToll
Basically fetch() will only reject a promise if the user is offline, or some unlikely networking error occurs, such a DNS lookup failure....
Read more >
Python KeyError Exceptions and How to Handle Them
Python's official documentation says that the KeyError is raised when a mapping key is accessed and isn't found in the mapping. A mapping...
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