test: Add test for http2.server.stream.finish diagnostics channel#740
Merged
test: Add test for http2.server.stream.finish diagnostics channel#740
Conversation
Agent-Logs-Url: https://github.com/node-modules/urllib/sessions/742bf4a1-b8cd-4c48-b7a9-99fcabc2e3d0 Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
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
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Member
|
@codex review |
There was a problem hiding this comment.
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.finishduring an HTTP/2 secure server test. - Sends HEAD and GET requests via
HttpClientwithallowH2: true. - Asserts the published message contains
stream,headers, andflagswith 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Node.js added the
http2.server.stream.finishdiagnostics channel in nodejs/node#58560, which fires whenServerHttp2Stream.respond()succeeds. This adds test coverage verifying urllib works correctly with this channel.http2.server.stream.finishin an H2 test server scenarioHttpClientwithallowH2: truestream(ServerHttp2Stream),headers(object), andflags(number)