mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Console] Cancel http request to es on timeout (#135610)
* [Console] Cancel http request to es on timeout * Update proxyRequest.test Co-authored-by: Muhammad Ibragimov <muhammad.ibragimov@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
fd50544641
commit
b8599a8470
2 changed files with 6 additions and 3 deletions
|
@ -31,7 +31,7 @@ describe(`Console's send request`, () => {
|
|||
|
||||
it('correctly implements timeout and abort mechanism', async () => {
|
||||
fakeRequest = {
|
||||
abort: sinon.stub(),
|
||||
destroy: sinon.stub(),
|
||||
on() {},
|
||||
once() {},
|
||||
} as any;
|
||||
|
@ -47,7 +47,7 @@ describe(`Console's send request`, () => {
|
|||
fail('Should not reach here!');
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('Client request timeout');
|
||||
expect((fakeRequest.abort as sinon.SinonStub).calledOnce).toBe(true);
|
||||
expect((fakeRequest.destroy as sinon.SinonStub).calledOnce).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -113,7 +113,10 @@ export const proxyRequest = ({
|
|||
|
||||
const timeoutPromise = new Promise<any>((timeoutResolve, timeoutReject) => {
|
||||
setTimeout(() => {
|
||||
if (!req.aborted && !req.socket) req.abort();
|
||||
// Destroy the stream on timeout and close the connection.
|
||||
if (!req.destroyed) {
|
||||
req.destroy();
|
||||
}
|
||||
if (!resolved) {
|
||||
timeoutReject(Boom.gatewayTimeout('Client request timeout'));
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue