Error stack not exposed when axios error occurs inside `getInitialProps` function
See original GitHub issueBug report
Error stack not exposed when axios error occurs inside getInitialProps function
Describe the bug
In the getInitialProps function, the error page is not displayed properly in client side rendering when an error occurs due to axios.
Page code
// pages/example.js
...
ExamplePage.getInitialProps = () => {
// The code below throws a CORS error on the client side.
await axios.get('https://google.com');
...
return {}
}
...
Run script
// Run nextjs in development mode.
$ next dev
Expected behavior
If an error occurs in getInitialProps function when entering a page through next/route(route.push) on the client side, the error information should be exposed on the page, but if an axios error occurs, the error page is not exposed(As a result of testing, other errors except axios error are normally showing error information on the page.).
System information
- Browser Chrome
- Version of Next.js: 9.2.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
getInitialProps in Next.js does not get data from server
I have solved the issue. It occurred because I broke a simple rule. According to next.js document, there is a note saying.
Read more >Fetching and hydrating a Next.JS app using ... - Medium
When your app needs to process data from an external source (as in a fetch for a remote JSON file) you have two...
Read more >axioserror: connect econnrefused 127.0.0.1:8080 - You.com
This error originated either by throwing inside of an async fun ction without a catch block, or by rejecting a promise which was...
Read more >Advanced Features: Error Handling - Next.js
Handling Errors in Development ... When there is a runtime error during the development phase of your Next.js application, you will encounter an...
Read more >[Solved]-images is not rendering on webpage while mapping ...
Coding example for the question images is not rendering on webpage while mapping the image from data.js file in react js-Reactjs.
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 Free
Top 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

This is a known problem with axios because it rewrites the stack trace. I wrote about a workaround here: https://github.com/rafaelalmeidatk/TIL/issues/4
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.