Skip to content

Commit

Permalink
do not respond on already responded incoming request
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Oct 1, 2021
1 parent ff96b66 commit dc1e1b1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/server/http/router/response_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export class HapiResponseAdapter {
}

private toHapiResponse(kibanaResponse: KibanaResponse) {
if (this.isAlreadyAborted()) {
return this.responseToolkit.close;
}
if (kibanaResponse.options.bypassErrorFormat) {
return this.toSuccess(kibanaResponse);
}
Expand Down Expand Up @@ -145,6 +148,13 @@ export class HapiResponseAdapter {

return error;
}

private isAlreadyAborted() {
return (
this.responseToolkit.request.raw.req.aborted === true &&
this.responseToolkit.request.active() === false
);
}
}

function getErrorMessage(payload?: ResponseError): string {
Expand Down

0 comments on commit dc1e1b1

Please sign in to comment.