-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect body larger than maxBodyLength not correctly caught #1362
Comments
I'm having trouble duplicating this locally (and I actually went down quite a rabbit-hole of finding cases that get caught by Axios from Can you share an example that demonstrates the error? |
Keep in mind that follow-redirects's |
I tried to create a reproducible scenario, however the only way I'm able to trigger this error is while downloading images > 10MB from Gettyimages (which is an authenticated endpoint). Currently, |
For benefit of anyone landing here, @scragg0x is correct, the configuration param is in bytes.
|
Facing same issue . Even after adding maxContentLength: 52428890 to axios post request has not fixed it. |
Looks like the noting maxContentLength being in bytes is in the README now, which is good: It might be useful to indicate what the default for maxContentLength is. But it seems like it might just be inherited from |
Anyone interested in fixing the issue ? I have below code but still getting same error. const config = { const fileBuffer = fse.readFileSync(fullBinaryPath); axios.put(testData.uploadUrl, fileBuffer, config) |
Worked for me. I just changed the version in package.json "axios": "0.18.0", |
axios should default |
For anyone hitting this who wants the easy "opt-out" to disable body size checks entirely: Set |
This did not work for me: const { data } = await axios({
url,
responseType: 'stream',
maxContentLength: `Infinity`,
})
return new Promise((resolve, reject) => {
data.pipe(createWriteStream(image_path))
.on('finish', () => resolve(createReadStream(image_path)))
.on('error', e => reject(e));
}) |
Try Infinity without the quotes |
Summary
Recently #1323 has been fixed, however
follow-redirects
is still not correctly implemented: current version does not handle errors correctly.Indeed, if
maxBodyLength
is 10MB and the resource fetched after the redirect is bigger,follow-redirects
will emit an error but that error will occur outside of axios promise chain.Axios should intercept that error and reject the promise
Context
The text was updated successfully, but these errors were encountered: