Skip to content

test: Add test for http2.server.stream.finish diagnostics channel#740

Merged
fengmk2 merged 2 commits intomasterfrom
copilot/support-http2-server-stream-finish
Apr 16, 2026
Merged

test: Add test for http2.server.stream.finish diagnostics channel#740
fengmk2 merged 2 commits intomasterfrom
copilot/support-http2-server-stream-finish

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

Node.js added the http2.server.stream.finish diagnostics channel in nodejs/node#58560, which fires when ServerHttp2Stream.respond() succeeds. This adds test coverage verifying urllib works correctly with this channel.

  • Subscribe to http2.server.stream.finish in an H2 test server scenario
  • Make HEAD and GET requests via HttpClient with allowH2: true
  • Assert published messages contain valid stream (ServerHttp2Stream), headers (object), and flags (number)

Copilot AI changed the title [WIP] Add support for http2.server.stream.finish diagnostics channel Add test for http2.server.stream.finish diagnostics channel Apr 12, 2026
Copilot AI requested a review from fengmk2 April 12, 2026 12:10
@fengmk2 fengmk2 added this to the v5 milestone Apr 12, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 12, 2026

Open in StackBlitz

npm i https://pkg.pr.new/node-modules/urllib@740

commit: 6b0e217

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.60%. Comparing base (ca63296) to head (6b0e217).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #740   +/-   ##
=======================================
  Coverage   94.60%   94.60%           
=======================================
  Files          10       10           
  Lines         723      723           
  Branches      226      226           
=======================================
  Hits          684      684           
  Misses         36       36           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@fengmk2 fengmk2 marked this pull request as ready for review April 16, 2026 11:46
Copilot AI review requested due to automatic review settings April 16, 2026 11:46
@fengmk2 fengmk2 changed the title Add test for http2.server.stream.finish diagnostics channel test: Add test for http2.server.stream.finish diagnostics channel Apr 16, 2026
@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented Apr 16, 2026

@codex review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new diagnostic-channel-focused test to ensure urllib behaves correctly when Node publishes the http2.server.stream.finish event during successful ServerHttp2Stream.respond() calls.

Changes:

  • Subscribes to http2.server.stream.finish during an HTTP/2 secure server test.
  • Sends HEAD and GET requests via HttpClient with allowH2: true.
  • Asserts the published message contains stream, headers, and flags with expected shapes/types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +327 to +336
await sleep(1);

// GET request
response = await httpClient.request(`https://localhost:${(server.address() as AddressInfo).port}`, {
method: 'GET',
});
assert.equal(response.status, 200);

assert.equal(finishMessages.length, 2);
for (const msg of finishMessages) {
Comment on lines +314 to +344
const httpClient = new HttpClient({
allowH2: true,
connect: {
rejectUnauthorized: false,
},
});

// HEAD request
let response = await httpClient.request(`https://localhost:${(server.address() as AddressInfo).port}?head=true`, {
method: 'HEAD',
});
assert.equal(response.status, 200);

await sleep(1);

// GET request
response = await httpClient.request(`https://localhost:${(server.address() as AddressInfo).port}`, {
method: 'GET',
});
assert.equal(response.status, 200);

assert.equal(finishMessages.length, 2);
for (const msg of finishMessages) {
assert.ok(msg.stream instanceof Duplex);
assert.equal(msg.stream.constructor.name, 'ServerHttp2Stream');
assert.ok(msg.headers && typeof msg.headers === 'object' && !Array.isArray(msg.headers));
assert.equal(typeof msg.flags, 'number');
}

diagnosticsChannel.unsubscribe('http2.server.stream.finish', onFinishMessage);
server.close();
@fengmk2 fengmk2 merged commit 702294e into master Apr 16, 2026
23 checks passed
@fengmk2 fengmk2 deleted the copilot/support-http2-server-stream-finish branch April 16, 2026 13:37
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.

support http2.server.stream.finish diagnostics channel

3 participants