Skip to content

http2: flush final GOAWAY after pending writes - #66834

Open
emerzon wants to merge 1 commit into
nodejs:mainfrom
emerzon:fix/http2-destroy-goaway
Open

emerzon wants to merge 1 commit into
nodejs:mainfrom
emerzon:fix/http2-destroy-goaway

Conversation

@emerzon

@emerzon emerzon commented Oct 18, 2026

Copy link
Copy Markdown

Keep the native session close pending when an active socket write prevents the terminal GOAWAY from being serialized. Resume shutdown after the write completes, preserving the requested HTTP/2 error code. On write failure, finish shutdown without retrying protocol writes and retain the listener needed to observe socket closure.

Add a deterministic regression using a controlled Duplex transport. It covers destruction inside and outside the receive callback with default and custom GOAWAY codes.

Validation: 296 HTTP/2 tests pass. The new regression and the existing TLS session reuse test each pass 50 repeated runs. The issue's original reproducer changes from sawGoaway=false to sawGoaway=true while the earlier write is still active. JavaScript and C++ lint and import checks pass.

Two local connection tests (test-http2-client-port-80 and test-http2-connect) also hang on unmodified HEAD; they were excluded from the successful 296-test run. Full Node.js CI remains pending.

Fixes: #66832

AI assistance: Codex assisted with implementation, testing, and this draft.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

Keep the native close pending when an active socket write prevents the
terminal GOAWAY from being serialized. Finish the close after the
outgoing buffers become available, preserving the requested error code.

Handle synchronous completion and transport errors without retrying
writes to a failed transport or losing the socket close notification.

Add a deterministic regression for default and custom GOAWAY codes, both
inside and outside the receive callback.

Fixes: nodejs#66832
Assisted-by: Codex
Signed-off-by: Emerson Gomes <emerson.gomes@gmail.com>
@emerzon
emerzon force-pushed the fix/http2-destroy-goaway branch from 7e40c3e to db1b93a Compare October 18, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http2: session.destroy() drops final GOAWAY when a write is in flight

2 participants