From bcd5581d208cd372055afdcb2fd10b68ca40613c Mon Sep 17 00:00:00 2001 From: Dmitriy Mozgovoy Date: Tue, 28 Oct 2025 20:44:08 +0200 Subject: [PATCH] fix(http): fixed a regression that caused the data stream to be interrupted for responses with non-OK HTTP statuses; (#7193) --- lib/adapters/http.js | 2 +- test/unit/adapters/http.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 5326dd03..49d3f949 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -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; diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index 7d0cf186..6c4375a5 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -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'); + } + }); });