fix(http): fixed a regression that caused the data stream to be interrupted for responses with non-OK HTTP statuses; (#7193)

This commit is contained in:
Dmitriy Mozgovoy 2025-10-28 20:44:08 +02:00 committed by GitHub
parent c9b33712aa
commit bcd5581d20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -737,7 +737,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
if (responseType === 'stream') {
response.data = responseStream;
settle(resolve, abort, response);
settle(resolve, reject, response);
} else {
const responseBuffer = [];
let totalResponseBytes = 0;

View File

@ -2665,6 +2665,23 @@ describe('supports http with nodejs', function () {
});
});
});
it('should not abort stream on settle rejection', async () => {
server = await startHTTPServer((req, res) => {
res.statusCode = 404;
res.end('OK');
});
try {
await axios.get(LOCAL_SERVER_URL, {
responseType: 'stream'
});
assert.fail('should be rejected');
} catch(err) {
assert.strictEqual(await getStream(err.response.data), 'OK');
}
});
});