Skip to content

Commit

Permalink
yup, that's simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Feb 23, 2022
1 parent f9129eb commit be0a2f6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/core/server/http/router/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { URL } from 'url';
import uuid from 'uuid';
import { Request, RouteOptionsApp, RequestApplicationState, RouteOptions } from '@hapi/hapi';
import { Observable, fromEvent, merge } from 'rxjs';
import { Observable, fromEvent } from 'rxjs';
import { shareReplay, first, filter } from 'rxjs/operators';
import { RecursiveReadonly } from '@kbn/utility-types';
import { deepFreeze } from '@kbn/std';
Expand Down Expand Up @@ -216,14 +216,9 @@ export class KibanaRequest<
}

private getEvents(request: Request): KibanaRequestEvents {
const closed$ = fromEvent<void>(request.raw.res, 'close').pipe(shareReplay(1), first());

// the response is completed
const finished$ = closed$.pipe(filter(() => isCompleted(request)));
const completed$ = fromEvent<void>(request.raw.res, 'close').pipe(shareReplay(1), first());
// the response's underlying connection was terminated prematurely
const aborted$ = closed$.pipe(filter(() => !isCompleted(request)));
// the response was either finished or aborted
const completed$ = merge<void, void>(finished$, aborted$);
const aborted$ = completed$.pipe(filter(() => !isCompleted(request)));

return {
aborted$,
Expand Down

0 comments on commit be0a2f6

Please sign in to comment.