Repository navigation
feat(DEP0207): migrate HTTP/2 'aborted' listeners to 'close' - #580
Open
FrustratedBoy420 wants to merge 1 commit into
Open
FrustratedBoy420 wants to merge 1 commit into
FrustratedBoy420 wants to merge 1 commit into
Conversation
Add the http2-aborted-to-close recipe. It applies one chosen strategy
("run this handler when the writable side did not finish"): an inline
'aborted' listener with no parameters on a locally resolved
Http2Stream becomes a 'close' listener wrapped in
`if (!stream.writableFinished)`.
Resolved streams: the first parameter of a 'stream' listener on a
createServer()/createSecureServer() server, and session.request()
results on a connect() session.
Reported, not rewritten: .aborted property reads, named listeners or
listeners with parameters, and streams whose 'aborted' listeners are
removed, counted or listed. The compatibility API and read-side
'error' handling are left alone.
Closes nodejs#558
Assisted-by: Claude Code (claude-opus-5-5)
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.
Closes #558
What it does
Adds the
http2-aborted-to-closerecipe for DEP0207. It applies one chosen strategy, "run this handler when the writable side did not finish before the stream closed", which matches the write-side example in the DEP0207 docs:server.on('stream', (stream) => { - stream.on('aborted', () => { - recordIncompleteResponse(); + stream.on('close', () => { + if (!stream.writableFinished) { + recordIncompleteResponse(); + } }); });Scope follows the issue:
'stream'listener on acreateServer()/createSecureServer()server, andsession.request()results on aconnect()session. Works withhttp2andnode:http2fromrequireorimport(default, namespace, named and aliased).on,once,addListener,prependListener,prependOnceListener). Block and expression bodies are both handled..abortedproperty reads, named listeners or listeners with parameters, and every'aborted'listener on a stream whose'aborted'listeners are also removed, counted or listed (off,removeListener,removeAllListeners,listeners,rawListeners,listenerCount).createServer((req, res) => …)) and read-side'error'handling.Tests
9 cases: CJS server, ESM aliased
createSecureServerwithonceand afunctionlistener, clientrequest()with an expression body, chainedcreateServer().on('stream', …)with 2-space indentation, TypeScript typed parameters, and four "unchanged" cases (named/parameterised listeners plus a.abortedread,removeAllListeners('aborted'), the compat API, and a file withouthttp2).npm testin the recipe,biome lintandtsc --noEmitpass.Runtime check and a question
The issue asks to validate the rewrite against normal completion, peer reset, local destruction, and writes ended but not finished. I ran those four cases on Node.js 25 (the only version I have locally), recording whether
'aborted'fired and whether!writableFinishedwas true at'close':'aborted'close&&!writableFinisheddestroy()end()called, not finished, then peer resetOn Node 25 the new pattern misses a peer reset, because the writable side is already finished by
'close'. As far as I can tell, nodejs/node#63249 (Node 27) changes this reset handling, and that is why the docs recommend this pattern, but I could not test Node 27 here. The README says to run the codemod when moving to Node.js 27. Could someone confirm the peer-reset row on 27?AI assistance
I used Claude Code (claude-opus-5-5) to help write the transform, tests and README, and to run the runtime check above. I reviewed every line and can explain it. The commit has an
Assisted-bytrailer, following the OpenJS AI coding assistants policy.