mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Console] Add context to client request timeout (#206742)
This commit is contained in:
parent
a514c26d38
commit
8be69aa77f
2 changed files with 15 additions and 3 deletions
|
@ -55,12 +55,18 @@ describe(`Console's send request`, () => {
|
|||
destroy: sinon.stub(),
|
||||
on() {},
|
||||
once() {},
|
||||
protocol: 'http:',
|
||||
host: 'nowhere.none',
|
||||
method: 'POST',
|
||||
path: '/_bulk',
|
||||
} as any;
|
||||
try {
|
||||
await sendProxyRequest({ timeout: 0 }); // immediately timeout
|
||||
fail('Should not reach here!');
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('Client request timeout');
|
||||
expect(e.message).toEqual(
|
||||
'Client request timeout for: http://nowhere.none with request POST /_bulk'
|
||||
);
|
||||
expect((fakeRequest.destroy as sinon.SinonStub).calledOnce).toBe(true);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -55,12 +55,13 @@ export const proxyRequest = ({
|
|||
finalUserHeaders.host = hostname;
|
||||
}
|
||||
|
||||
const parsedPort = port === '' ? undefined : parseInt(port, 10);
|
||||
const req = client.request({
|
||||
method: method.toUpperCase(),
|
||||
// We support overriding this on a per request basis to support legacy proxy config. See ./proxy_config.
|
||||
rejectUnauthorized: typeof rejectUnauthorized === 'boolean' ? rejectUnauthorized : undefined,
|
||||
host: sanitizeHostname(hostname),
|
||||
port: port === '' ? undefined : parseInt(port, 10),
|
||||
port: parsedPort,
|
||||
protocol,
|
||||
path: `${pathname}${search || ''}`,
|
||||
headers: {
|
||||
|
@ -96,7 +97,12 @@ export const proxyRequest = ({
|
|||
req.destroy();
|
||||
}
|
||||
if (!resolved) {
|
||||
timeoutReject(Boom.gatewayTimeout('Client request timeout'));
|
||||
const request = `${req.method} ${req.path}`;
|
||||
const requestPath = `${req.protocol}//${req.host}${parsedPort ? `:${parsedPort}` : ''}`;
|
||||
|
||||
timeoutReject(
|
||||
Boom.gatewayTimeout(`Client request timeout for: ${requestPath} with request ${request}`)
|
||||
);
|
||||
} else {
|
||||
timeoutResolve(undefined);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue