-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NOT FOR MERGE] TSVB abort is not working #125069
Conversation
Hey @elastic/kibana-core, we're trying to figure out why |
request.events.aborted$.subscribe(() => { | ||
console.log('tsvb: abort is not working'); | ||
}); | ||
|
||
request.events.completed$.subscribe(() => { | ||
console.log('tsvb: completed$ is working'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference I see it that in the non-working handler, you're subscribing to both observables when in the other, you're only subscribing to aborted$
. Could it be the thing? (in which case it would totally be a bug on our side)
FWIW, these observables are coming from here:
kibana/src/core/server/http/router/request.ts
Lines 217 to 228 in 338fe1a
private getEvents(request: Request): KibanaRequestEvents { | |
// the response is completed, or its underlying connection was terminated prematurely | |
const finish$ = fromEvent(request.raw.res, 'close').pipe(shareReplay(1), first()); | |
const aborted$ = fromEvent<void>(request.raw.req, 'aborted').pipe(first(), takeUntil(finish$)); | |
const completed$ = merge<void, void>(finish$, aborted$).pipe(shareReplay(1), first()); | |
return { | |
aborted$, | |
completed$, | |
} as const; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mshustov do you know why we don't have a shareReplay
(or just replay
) effect on aborted$
btw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected Hapi to terminate request handling if an underlying request is aborted. But we can add shareReplay
to be extra-safe. We already discussed it during the initial implementation #55061 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference I see it that in the non-working handler, you're subscribing to both observables when in the other, you're only subscribing to aborted$. Could it be the thing?
Nope, doesn't seem to change anything even if I don't subscribe to completed
events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I just noticed that Node.js sets the aborted
event as deprecated. It should still work for v16... but we should look at migrating away from it.
#125069 was created, this PR can be closed |
Summary
I made similar changes in two places, for some reason it works in examples but doesn't work in TSVB
TSVB:
To play just open any TSVB visualization and see console.
Expected: I expect to see '
tsvb: abort is not working'
in consoleScreen.Recording.2022-02-09.at.4.11.49.PM.mov
Examples:
/app/searchExamples/search
Request from low-level client on the server
Screen.Recording.2022-02-09.at.4.09.15.PM.mov