-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Axios Unable to Handle "204 No Content" Responses #6327
Comments
I can't reproduce const res = await axios.get('https://httpbin.org/status/204');
console.log(res.status, res.statusText); // 204 NO CONTENT |
I've the same / a similar issue. Unfortunately I cannot disclose the URL but I can contribute some more details: Axios Version
Node Versionwas able to reproduce it with package.json{
"name": "axios-test",
"version": "1.0.0",
"description": "",
"main": "app.js",
"type": "module",
"dependencies": {
"axios": "~0.28.1"
}
} Code Snippet (minimal example)#!/usr/bin/env node
import axios from 'axios';
axios.get('https://foo.bar/health/')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.finally(function () {}); LogExpand code...
Interestingly the request works setting the request header to Looks like it is somehow related to #5246 |
@DigitalBrainJS Please let me know if you need any further information to track this issue down. I'd be very happy to provide the necessary details if possible. |
@ttomasini This is a known issue in Axios 0.x. Axios 1.x fixes a batch of issues related to response decompression in node.js, including this one. (#5306, #4701) |
@DigitalBrainJS Thank you for the quick answer Dmitriy! That's good to know. I just wonder why it works/worked flawlessly in |
@yuchen001 I was returning the following from the backend
Then I did the following and the client worked fine.
Not sure why it was working with previous axios. |
bump |
Describe the bug
As of today, Axios seems to be unable to handle requests that result in a "204 No Content" response. Any API request that responds with a 204 status code is treated as a timeout.
Preliminary testing and investigation suggest that the issue might be related to Axios instances.
It might be challenging to provide a publicly accessible test case since finding APIs that reliably respond with a 204 status code could be difficult.
To Reproduce
As of the latest observation, Axios encounters an issue where responses with an empty body (e.g., "204 No Content") are incorrectly treated as timeouts when using an Axios instance.
Notably, when requests are made without creating an Axios instance directly, the behavior is as expected.
Steps to Reproduce:
Code snippet
No response
Expected behavior
Axios should accurately handle responses with an empty body, such as 204 status codes, without treating them as timeouts.
Axios Version
No response
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: