Skip to content

fix(node): stop http2 file reads on stream close#36061

Open
nathanwhit wants to merge 1 commit into
denoland:mainfrom
nathanwhit:fix/http2-file-read-cancellation
Open

fix(node): stop http2 file reads on stream close#36061
nathanwhit wants to merge 1 commit into
denoland:mainfrom
nathanwhit:fix/http2-file-read-cancellation

Conversation

@nathanwhit

Copy link
Copy Markdown
Member

Summary

  • stop respondWithFile() and respondWithFD() read loops when their HTTP/2 stream closes or a write fails
  • close file descriptors owned by respondWithFile() while preserving caller ownership for respondWithFD()
  • add regression coverage for both ownership paths

Motivation

The JavaScript file-response loop chained each fs.read() through the previous stream write callback without checking the stream lifecycle or callback error. A closed stream could therefore continue scheduling reads. The cleanup path now stops the loop immediately and applies the appropriate descriptor ownership rule.

Validation

  • ./tools/format.js
  • cargo build --bin deno
  • cargo test -p unit_node_tests --test unit_node -- http2_test
  • cargo test -p node_compat_tests --test node_compat test-http2-respond -- --nocapture (22 tests)

@nathanwhit nathanwhit marked this pull request as ready for review July 15, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant