2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

chore: matches the sibling responseStream.on(aborted) handler and added tests (#7149)

Co-authored-by: Jason Saayman <jasonsaayman@gmail.com>
This commit is contained in:
Edgars Beigarts
2026-04-29 20:21:03 +03:00
committed by GitHub
parent 9fcdf48811
commit cd6737fd84
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -912,7 +912,7 @@ export default isHttpAdapterSupported &&
});
responseStream.on('error', function handleStreamError(err) {
if (req.destroyed) return;
if (rejected) return;
reject(AxiosError.from(err, null, config, lastRequest, response));
});
+22
View File
@@ -823,6 +823,28 @@ describe('supports http with nodejs', () => {
await stopHTTPServer(server);
}
});
it('should reject when the server aborts mid-stream and maxRedirects is 0', async () => {
const server = await startHTTPServer(
async (req, res) => {
res.setHeader('Content-Encoding', type);
res.setHeader('Transfer-Encoding', 'chunked');
res.removeHeader('Content-Length');
res.write(await zipped);
setTimeout(() => res.socket.destroy(), 10);
},
{ port: SERVER_PORT }
);
try {
await assert.rejects(
axios.get(`http://localhost:${server.address().port}`, { maxRedirects: 0 }),
(err) => err && err.code === 'ECONNRESET'
);
} finally {
await stopHTTPServer(server);
}
});
});
}
});