test: fix flaky test-http2-close-while-writing by mcollina · Pull Request #61764 · nodejs/node · GitHub
Skip to content

test: fix flaky test-http2-close-while-writing#61764

Closed
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-flaky-test-http2-close-while-writing
Closed

test: fix flaky test-http2-close-while-writing#61764
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-flaky-test-http2-close-while-writing

Conversation

@mcollina

Copy link
Copy Markdown
Member

Summary

Fixes flaky test test/parallel/test-http2-close-while-writing.js which was timing out on macOS.

Problem

The test uses stream.on('data', ...) which can fire multiple times when receiving the 64KB data chunk sent by the client. Each data event triggers client_stream.destroy() via process.nextTick(), leading to multiple destroy calls and intermittent timeouts.

Solution

Changed stream.on('data', ...) to stream.once('data', ...) to ensure the callback only fires once, regardless of how many data chunks arrive. This pattern is consistent with similar tests like test-http2-many-writes-and-destroy.js.

Verification

Verified with python3 tools/test.py --repeat 100 without failures.

Refs: nodejs/reliability#1459

Use stream.once() instead of stream.on() for the 'data' event
handler to prevent multiple calls when receiving large data chunks.
The test sends 64KB of data which may arrive in multiple chunks,
causing the destroy callback to fire multiple times and leading
to intermittent timeouts on macOS.

Refs: nodejs/reliability#1459
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Feb 10, 2026
@codecov

codecov Bot commented Feb 10, 2026

Copy link
Copy Markdown

@lpinca lpinca 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.

See #58252, there is a deeper issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants