From be0a2f6172144dbef6dba3124307dc202e9d81c8 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 23 Feb 2022 13:59:48 +0100 Subject: [PATCH] yup, that's simpler --- src/core/server/http/router/request.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/core/server/http/router/request.ts b/src/core/server/http/router/request.ts index 004332450d75a..5a914fb800da9 100644 --- a/src/core/server/http/router/request.ts +++ b/src/core/server/http/router/request.ts @@ -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'; @@ -216,14 +216,9 @@ export class KibanaRequest< } private getEvents(request: Request): KibanaRequestEvents { - const closed$ = fromEvent(request.raw.res, 'close').pipe(shareReplay(1), first()); - - // the response is completed - const finished$ = closed$.pipe(filter(() => isCompleted(request))); + const completed$ = fromEvent(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(finished$, aborted$); + const aborted$ = completed$.pipe(filter(() => !isCompleted(request))); return { aborted$,