From c0acd739e2fbc00c3784f688ca12a265e0a289a0 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 10 Feb 2026 19:25:20 +0100 Subject: [PATCH] test: fix flaky test-http2-close-while-writing 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 --- test/parallel/test-http2-close-while-writing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-http2-close-while-writing.js b/test/parallel/test-http2-close-while-writing.js index c0a05c4a8da21a..abfdf26c3e71f0 100644 --- a/test/parallel/test-http2-close-while-writing.js +++ b/test/parallel/test-http2-close-while-writing.js @@ -24,7 +24,7 @@ let client_stream; server.on('session', common.mustCall(function(session) { session.on('stream', common.mustCall(function(stream) { stream.resume(); - stream.on('data', function() { + stream.once('data', function() { this.write(Buffer.alloc(1)); process.nextTick(() => client_stream.destroy()); });