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 413 does not contain status code

See original GitHub issue

#### Summary

In the follow code snippet,

axios.post('/api/files/new', formData, config)
    .then(response => this.fileUploaded(response.data, name, size))
    .catch(e => {
        console.log('error uploading file:')
        console.warn(e.response)
    })

if the api rejects with 413 (“file too large”), e.response is undefined. Multiple reasons can lead to a nul response, and we need to be able to distinguish. In this case, at the reject phase, that status is lost.

At the same time, servers should not have to attach response bodies for all forms of malformed requests.

#### Context

  • axios version: 0.15.3
  • Environment: vueJS/node custom project

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:7

github_iconTop GitHub Comments

1reaction
raygesualdocommented, Jan 8, 2018

Hey all, I took a few minutes to troubleshoot this issue. Here are some things I found:

  1. I created an example of @robbiemu’s code that works. The codesandbox can be viewed here: https://codesandbox.io/s/80jv7k528. Note that while the example makes a cross-domain request, the server is correctly configured for CORS. Let me know if that is helpful.
  2. I found that, when making a cross-domain request, if the server isn’t correctly configured for CORS, axios returns an error without error.response populated. This is because the XHR request fails at the browser level (during the OPTIONS call), which is technically a network error. For network errors, axios does not provide a response because one is not provided by the browser. If one debugs the network error returned to axios from an invalid OPTIONS call, one will notice that there is no way to know the status.
0reactions
chinesedfancommented, Mar 8, 2020

I think the reason is validateStatus. See my notes. And feel free to remind me if it is not solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Solve the "413 Request Entity Too Large" Error - Kinsta
In a nutshell, the “413 Request Entity Too Large” error is a size issue. It happens when a client makes a request that's...
Read more >
Getting HTTP Error 413 Request entity too large when ... - Poly
The 413 status code indicates that the request was larger than the server can handle, either due to physical constraints or settings. Why...
Read more >
PageRequestManagerServerErr...
The 413 status code indicates that the request was larger than the server is able to handle, either due to physical constraints or...
Read more >
Fixing 413 Request Entity Too Large Errors - KeyCDN Support
Fixing this error is about increasing the maximum file size for the server in question. Once that is done, the error should no...
Read more >
413 HTTP Response Status Code Definition - Holistic SEO
The 413 HTTP Status Code indicates that the server is refusing to process a request because the request payload is too large for...
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