[8.19] [Core] Fix KibanaRequest aborted$ never emitting for HTTP/2 requests (#285244) - #285403
Merged
Conversation
…lastic#285244) ## Human summary Improves the detection of completed requests by additionally checking for `res.writableEnded`. This works around a quirk in Node.js when running in http/2, which is resolved in 26+: nodejs/node#63249. Checking for `res.writableEnded` does not change anything when running in http/1, as this is always true when `res.writableFinished`. This changes behavior for http/2 by properly detecting aborted requests. This should result in downstream consumers having a more reliable signal for when a client request is aborted, allowing them to cancel jobs such as in-flight ES requests regardless of http protocol. We detected this while writing scout tests for elastic#285153 ## AI description When an HTTP/2 client destroys a stream mid-request (RST_STREAM / NGHTTP2_CANCEL, e.g. an AbortController cancel or browser navigation), Node's Http2ServerResponse emits 'close' with writableFinished === true even though nothing was written. isCompleted() relied on writableFinished alone, so the !isCompleted filter swallowed the event and request.events.aborted$ never fired — consumers (route handlers, auth providers) could not observe HTTP/2 client aborts. HTTP/1 was unaffected because writableFinished stays false there. Treat a request as completed only when writableFinished && writableEnded: writableEnded only becomes true once the server actually ended the response, and is truthful on both protocols and for abrupt TCP-level disconnects. Adds integration coverage in http2_protocol.test.ts driving a real HTTP/2 TLS session that resets the stream while the handler is pending, plus a control test asserting completed$ (and not aborted$) on normal completion. Co-authored-by: Claude Fable 5 <[email protected]> (cherry picked from commit a19e27a) # Conflicts: # src/core/server/integration_tests/http/http2_protocol.test.ts
legrego
enabled auto-merge (squash)
August 17, 2026 13:18
kibanamachine
requested review from
Bamieh
and removed request for
kibanamachine
August 17, 2026 13:18
azasypkin
approved these changes
Aug 19, 2026
Contributor
💚 Build Succeeded
Metrics [docs]Page load bundle
History
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto8.19:Questions ?
Please refer to the Backport tool documentation