Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: deflake test-http2-debug
Native debug writes can be lost when the non-blocking stderr pipe fills,
leaving expected log lines missing even when the child exits
successfully. Capture stderr in a temporary file and apply the existing
assertions to its contents. Remove the flaky designation on Linux s390x.

Fixes: #58353
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
  • Loading branch information
panva committed Sep 20, 2026
commit 83f90596531c1b76f2fd28798a8e1ae1a878d037
4 changes: 0 additions & 4 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ test-performance-function: PASS, FLAKY
# https://github.com/nodejs/node/issues/54346
test-esm-loader-hooks-inspect-wait: PASS, FLAKY

[$system==linux && $arch==s390x]
# https://github.com/nodejs/node/issues/58353
test-http2-debug: PASS, FLAKY

[$system==macos]
# https://github.com/nodejs/node/issues/42741
test-http-server-headers-timeout-keepalive: PASS,FLAKY
Expand Down
54 changes: 32 additions & 22 deletions test/parallel/test-http2-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,37 @@ if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const { spawnSyncAndAssert } = require('../common/child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');

spawnSyncAndAssert(process.execPath, [
path.resolve(__dirname, 'test-http2-ping.js'),
], {
env: {
...process.env,
NODE_DEBUG: 'http2',
NODE_DEBUG_NATIVE: 'http2',
},
}, {
trim: true,
stderr(output) {
assert.match(output,
/Setting the NODE_DEBUG environment variable to 'http2' can expose sensitive data/);
assert.match(output, /\(such as passwords, tokens and authentication headers\) in the resulting log\.\r?\n/);
assert.match(output, /Http2Session client \(\d+\) handling data frame for stream \d+\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] reading starting\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] closed with code 0\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] closed with code 0\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] tearing down stream\r?\n/);
},
stdout: ''
});
tmpdir.refresh();
const stderrFile = tmpdir.resolve('stderr.log');
// Native debug writes can be lost when a non-blocking stderr pipe fills.
const stderrFd = fs.openSync(stderrFile, 'w');
try {
spawnSyncAndAssert(process.execPath, [
path.resolve(__dirname, 'test-http2-ping.js'),
], {
env: {
...process.env,
NODE_DEBUG: 'http2',
NODE_DEBUG_NATIVE: 'http2',
},
stdio: ['pipe', 'pipe', stderrFd],
}, {
stdout: ''
});
} finally {
fs.closeSync(stderrFd);
}

const output = fs.readFileSync(stderrFile, 'utf8');
assert.match(output,
/Setting the NODE_DEBUG environment variable to 'http2' can expose sensitive data/);
assert.match(output, /\(such as passwords, tokens and authentication headers\) in the resulting log\.\r?\n/);
assert.match(output, /Http2Session client \(\d+\) handling data frame for stream \d+\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] reading starting\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] closed with code 0\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] closed with code 0\r?\n/);
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] tearing down stream\r?\n/);
Loading