mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
fix(http): fix 'socket hang up' bug for keep-alive requests when using timeouts; (#7206)
This commit is contained in:
@@ -858,6 +858,9 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|||||||
req
|
req
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// explicitly reset the socket timeout value for a possible `keep-alive` request
|
||||||
|
req.setTimeout(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2682,6 +2682,21 @@ describe('supports http with nodejs', function () {
|
|||||||
assert.strictEqual(await getStream(err.response.data), 'OK');
|
assert.strictEqual(await getStream(err.response.data), 'OK');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('keep-alive', () => {
|
||||||
|
it('should not fail with "socket hang up" when using timeouts', async () => {
|
||||||
|
server = await startHTTPServer(async (req, res) => {
|
||||||
|
if (req.url === '/wait') {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||||
|
}
|
||||||
|
res.end('ok');
|
||||||
|
})
|
||||||
|
|
||||||
|
const baseURL = LOCAL_SERVER_URL;
|
||||||
|
await axios.get('/1', {baseURL, timeout: 1000});
|
||||||
|
await axios.get(`/wait`, {baseURL, timeout: 0});
|
||||||
|
}, 15000);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user