Skip to content

http2: destroy compat stream on request timeout - #67832

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:http2-compat-timeout-destroy
Dec 4, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:http2-compat-timeout-destroy

Conversation

@mcollina

Copy link
Copy Markdown
Member

When a request times out and no 'timeout' handler is attached to the request or response, the HTTP/2 compatibility layer now destroys the stream, matching the HTTP/1 behavior where the underlying socket is destroyed. This prevents a response from being sent after the timeout.

Fixes: #67820

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Nov 27, 2026
When a request times out and no 'timeout' handler is attached to the
request or response, the HTTP/2 compatibility layer now destroys the
stream, matching the HTTP/1 behavior where the underlying socket is
destroyed. This prevents a response from being sent after the timeout.

The compat layer re-emits the stream 'timeout' event on the request and
response objects and only keeps the stream open if one of them handled
it. Request/response setTimeout now register their callback on the
request/response object, as HTTP/1 does, so that a Timeout callback
counts as handling the event.

Refs: nodejs#67820
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollina force-pushed the http2-compat-timeout-destroy branch from 161cc90 to 49f4152 Compare November 27, 2026 17:51
@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.96%. Comparing base (72bf392) to head (49f4152).
⚠️ Report is 160 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67832      +/-   ##
==========================================
+ Coverage   90.49%   90.96%   +0.46%     
==========================================
  Files         805      805              
  Lines      285806   291448    +5642     
  Branches    55172    61032    +5860     
==========================================
+ Hits       258647   265104    +6457     
+ Misses      17250    16514     -736     
+ Partials     9909     9830      -79     
Files with missing lines Coverage Δ
lib/internal/http2/compat.js 98.65% <100.00%> (+1.23%) ⬆️

... and 121 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Dec 1, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Dec 1, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@gurgunday gurgunday added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Dec 1, 2026
@mcollina

mcollina commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #67821.

@mcollina mcollina closed this Dec 1, 2026
@inoway46

inoway46 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

My PR (#67821) fixes req.destroy(), but the HTTP/2 client still receives OK-after-timeout when I run the reproducer from #67820 with that change. Would you be open to reopening this? Sorry if mentioning #67820 in my PR description caused any confusion.

@mcollina mcollina reopened this Dec 2, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollina mcollina added the commit-queue PRs queued for automated landing through the Commit Queue. label Dec 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 0c5be9d into nodejs:main Dec 4, 2026
97 of 98 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0c5be9d

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. 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 compat: stream is not destroyed on request timeout, unlike http1 socket

7 participants