Skip to content

feat(DEP0207): migrate HTTP/2 abort handling to standard stream events #558

Open

Description

@bjohansebas

Node.js 27.0.0-alpha.0.0.0 introduces DEP0207, a documentation-only deprecation of the .aborted property and 'aborted' event in node:http2.

Explore a partial codemod for handlers whose purpose is known: detecting that the writable side did not finish before the stream closed. The documented migration uses a 'close' listener and checks writableFinished.

The migration must require the user to select the intended write-side behavior. It cannot safely infer that intention from the event name alone.

Additional Information

  • This is a documentation-only deprecation in this alpha. The deprecated members remain available.
  • Limit the initial transformation to locally resolved Http2Stream bindings, using inline arrow-function listeners with no arguments and no listener-removal or ordering dependencies.
  • Changing an 'aborted' listener to 'close' can change timing and the situations that invoke the handler. In particular, writableFinished is not an exact synonym for the old event's writable-ended condition. Present the transformation as a selected migration strategy, not a universal semantics-preserving replacement.
  • Keep other 'close' listeners and error handling intact. Report cases with ambiguous read/write intent, external callbacks, or listener identity dependencies.
  • Read-side abort handling uses 'error' and codes such as ERR_HTTP2_STREAM_ABORTED and ERR_HTTP2_STREAM_ERROR. Adding error listeners can change exception handling, so exclude automatic read-side rewrites from the initial scope.
  • Report .aborted property reads for manual review. Do not blindly replace them with .destroyed, !writableFinished, or !readableEnded.
  • Treat the HTTP/2 compatibility API separately because request and response objects represent different sides of the exchange.
  • Validate selected transformations against normal completion, peer reset, local destruction, and writes ended but not yet finished.

Examples

Proposed output only after selecting the strategy "run this handler when the writable side fails to finish":

 import { createServer } from 'node:http2';

 const server = createServer();
 server.on('stream', (stream) => {
-  stream.on('aborted', () => {
-    recordIncompleteResponse();
+  stream.on('close', () => {
+    if (!stream.writableFinished) {
+      recordIncompleteResponse();
+    }
   });
 });

Keep arbitrary property reads unchanged and report them:

if (stream.aborted) {
  handleAbort();
}

Refs

Activity

  1. added
    good first issue human
    help wanted
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue humanhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions