Skip to content

Commit bcd5581

Browse files
fix(http): fixed a regression that caused the data stream to be interrupted for responses with non-OK HTTP statuses; (#7193)
1 parent c9b3371 commit bcd5581

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/adapters/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
737737

738738
if (responseType === 'stream') {
739739
response.data = responseStream;
740-
settle(resolve, abort, response);
740+
settle(resolve, reject, response);
741741
} else {
742742
const responseBuffer = [];
743743
let totalResponseBytes = 0;

test/unit/adapters/http.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,6 +2665,23 @@ describe('supports http with nodejs', function () {
26652665
});
26662666
});
26672667
});
2668+
2669+
it('should not abort stream on settle rejection', async () => {
2670+
server = await startHTTPServer((req, res) => {
2671+
res.statusCode = 404;
2672+
res.end('OK');
2673+
});
2674+
2675+
try {
2676+
await axios.get(LOCAL_SERVER_URL, {
2677+
responseType: 'stream'
2678+
});
2679+
2680+
assert.fail('should be rejected');
2681+
} catch(err) {
2682+
assert.strictEqual(await getStream(err.response.data), 'OK');
2683+
}
2684+
});
26682685
});
26692686

26702687

0 commit comments

Comments
 (0)