mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Propagate request cancelation though basePath proxy (#101561)
* bump `@hapi/h2o2` to `9.1.0` * add unit test
This commit is contained in:
parent
51e2da9630
commit
ebdda9e110
3 changed files with 44 additions and 5 deletions
|
@ -118,7 +118,7 @@
|
|||
"@hapi/boom": "^9.1.1",
|
||||
"@hapi/cookie": "^11.0.2",
|
||||
"@hapi/good-squeeze": "6.0.0",
|
||||
"@hapi/h2o2": "^9.0.2",
|
||||
"@hapi/h2o2": "^9.1.0",
|
||||
"@hapi/hapi": "^20.0.3",
|
||||
"@hapi/hoek": "^9.1.1",
|
||||
"@hapi/inert": "^6.0.3",
|
||||
|
|
|
@ -185,6 +185,45 @@ describe('BasePathProxyServer', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('forwards request cancellation', async () => {
|
||||
let propagated = false;
|
||||
|
||||
let notifyRequestReceived: () => void;
|
||||
const requestReceived = new Promise<void>((resolve) => {
|
||||
notifyRequestReceived = resolve;
|
||||
});
|
||||
|
||||
let notifyRequestAborted: () => void;
|
||||
const requestAborted = new Promise<void>((resolve) => {
|
||||
notifyRequestAborted = resolve;
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: `${basePath}/foo/{test}`,
|
||||
handler: async (request, h) => {
|
||||
notifyRequestReceived();
|
||||
|
||||
request.raw.req.once('aborted', () => {
|
||||
notifyRequestAborted();
|
||||
propagated = true;
|
||||
});
|
||||
return await new Promise((resolve) => undefined);
|
||||
},
|
||||
});
|
||||
await server.start();
|
||||
|
||||
const request = proxySupertest.get(`${basePath}/foo/some-string`).end();
|
||||
|
||||
await requestReceived;
|
||||
|
||||
request.abort();
|
||||
|
||||
await requestAborted;
|
||||
|
||||
expect(propagated).toEqual(true);
|
||||
});
|
||||
|
||||
test('handles putting', async () => {
|
||||
server.route({
|
||||
method: 'PUT',
|
||||
|
|
|
@ -1871,10 +1871,10 @@
|
|||
"@hapi/hoek" "9.x.x"
|
||||
fast-safe-stringify "2.x.x"
|
||||
|
||||
"@hapi/h2o2@^9.0.2":
|
||||
version "9.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/h2o2/-/h2o2-9.0.2.tgz#e9f1dfe789257c80d6ee37ec9fe358f8c69f855a"
|
||||
integrity sha512-V7RsmVyl7uyWeuEko4uaSZbFpBHKcSFSui6PXNRaRLJHFX+iPbqWmeH6m1pW/WJ8DuaCVJFKhluDCDI9l4+1cw==
|
||||
"@hapi/h2o2@^9.1.0":
|
||||
version "9.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/h2o2/-/h2o2-9.1.0.tgz#b223f4978b6f2b0d7d9db10a84a567606c4c3551"
|
||||
integrity sha512-B7E58bMhxmpiDI22clxTexoAaVShNBk1Ez6S8SQjQZu5FxxD6Tqa44sXeZQBtWrdJF7ZRbsY60/C8AHLRxagNA==
|
||||
dependencies:
|
||||
"@hapi/boom" "9.x.x"
|
||||
"@hapi/hoek" "9.x.x"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue