Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should got undici:client:sendHeaders message on H2 #553

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Dec 4, 2024

closes #510

Summary by CodeRabbit

  • New Features

    • Enhanced error handling and logging for HTTP requests, improving traceability of socket-related issues.
    • Augmented response diagnostics to include socket information for better monitoring.
  • Bug Fixes

    • Improved resilience against transient socket issues with refined error handling and retry logic.
  • Tests

    • Introduced a new test case for tracing socket information with HTTP/2, ensuring accurate socket reuse tracking.
  • Chores

    • Updated the version of the undici dependency in package.json.

Copy link

coderabbitai bot commented Dec 4, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request enhance the HttpClient class by refining error handling and logging mechanisms, particularly in the #requestInternal method. A new parameter for socket information is added to logging, and specific error types for timeouts are introduced. The updateSocketInfo function in src/utils.ts is also modified to improve the tracking of attempted remote addresses. Additionally, a new test case is introduced in test/diagnostics_channel.test.ts to verify socket tracing with HTTP/2 support.

Changes

File Change Summary
src/HttpClient.ts Enhanced error handling with specific timeout errors; improved logging with socket context; added retry logic for socket errors.
src/utils.ts Modified updateSocketInfo function to consolidate logic for setting attemptedRemoteAddresses.
test/diagnostics_channel.test.ts Added a new test case for tracing socket info with HTTP/2, verifying socket reuse in requests; modified imports for HttpClient.
package.json Updated undici dependency version from ^7.0.0 to ^7.1.1.

Assessment against linked issues

Objective Addressed Explanation
Ensure undici:client:sendHeaders event is not lost under HTTP/2 (510)

Poem

🐇 In the realm of code where the sockets play,
Errors now handled in a clearer way.
With logs that sparkle, and tests that gleam,
Our HttpClient dances, a developer's dream!
So hop along, let the bytes take flight,
For debugging's easier, and all feels right! ✨

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4358fb2 and 59a319f.

📒 Files selected for processing (4)
  • package.json (1 hunks)
  • src/HttpClient.ts (1 hunks)
  • src/utils.ts (1 hunks)
  • test/diagnostics_channel.test.ts (2 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Dec 4, 2024

Open in Stackblitz

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

commit: 59a319f

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 104664d and fdf7f07.

📒 Files selected for processing (3)
  • src/HttpClient.ts (1 hunks)
  • src/utils.ts (1 hunks)
  • test/diagnostics_channel.test.ts (2 hunks)
🧰 Additional context used
🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)
test/diagnostics_channel.test.ts

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ writeH1 node:internal/deps/undici/undici:6443:30
❯ Object.write node:internal/deps/undici/undici:6278:18
❯ _resume node:internal/deps/undici/undici:7945:54
❯ resume node:internal/deps/undici/undici:7881:7
❯ Client. node:internal/deps/undici/undici:7666:35
❯ connect node:internal/deps/undici/undici:7868:22

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6169:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5809:34
❯ null. wasm:/wasm/0002f80e:1:26723
❯ Parser.execute node:internal/deps/undici/undici:5922:26
❯ Parser.readMore node:internal/deps/undici/undici:5901:16
❯ Socket. node:internal/deps/undici/undici:6229:18
❯ Socket.emit node:events:518:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ writeH1 node:internal/deps/undici/undici:6443:30
❯ Object.write node:internal/deps/undici/undici:6278:18
❯ _resume node:internal/deps/undici/undici:7945:54
❯ resume node:internal/deps/undici/undici:7881:7
❯ Client. node:internal/deps/undici/undici:7666:35
❯ connect node:internal/deps/undici/undici:7868:22

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6169:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5809:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5922:26
❯ Parser.readMore node:internal/deps/undici/undici:5901:16
❯ Socket. node:internal/deps/undici/undici:6229:18
❯ Socket.emit node:events:518:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ writeH1 node:internal/deps/undici/undici:6443:30
❯ Object.write node:internal/deps/undici/undici:6278:18
❯ _resume node:internal/deps/undici/undici:7945:54
❯ resume node:internal/deps/undici/undici:7881:7
❯ Client. node:internal/deps/undici/undici:7666:35
❯ Client.[dispatch] node:internal/deps/undici/undici:7707:24
❯ Client.Intercept node:internal/deps/undici/undici:7435:20
❯ Client.dispatch node:internal/deps/undici/undici:588:44

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6169:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5809:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5922:26
❯ Parser.readMore node:internal/deps/undici/undici:5901:16
❯ Socket. node:internal/deps/undici/undici:6229:18
❯ Socket.emit node:events:518:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ writeH1 node:internal/deps/undici/undici:6443:30
❯ Object.write node:internal/deps/undici/undici:6278:18
❯ _resume node:internal/deps/undici/undici:7945:54
❯ resume node:internal/deps/undici/undici:7881:7
❯ Client. node:internal/deps/undici/undici:7666:35
❯ Client.[dispatch] node:internal/deps/undici/undici:7707:24
❯ Client.Intercept node:internal/deps/undici/undici:7435:20
❯ Client.dispatch node:internal/deps/undici/undici:588:44

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6169:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5809:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5922:26
❯ Parser.readMore node:internal/deps/undici/undici:5901:16
❯ Socket. node:internal/deps/undici/undici:6229:18
❯ Socket.emit node:events:518:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ writeH1 node:internal/deps/undici/undici:6443:30
❯ Object.write node:internal/deps/undici/undici:6278:18
❯ _resume node:internal/deps/undici/undici:7945:54
❯ resume node:internal/deps/undici/undici:7881:7
❯ Client. node:internal/deps/undici/undici:7666:35
❯ Client.[dispatch] node:internal/deps/undici/undici:7707:24
❯ Client.Intercept node:internal/deps/undici/undici:7435:20
❯ Client.dispatch node:internal/deps/undici/undici:588:44

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:143:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6169:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5809:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5922:26
❯ Parser.readMore node:internal/deps/undici/undici:5901:16
❯ Socket. node:internal/deps/undici/undici:6229:18
❯ Socket.emit node:events:518:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.
🪛 GitHub Check: Node.js / Test (ubuntu-latest, 23)
test/diagnostics_channel.test.ts

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ writeH1 node:internal/deps/undici/undici:6492:30
❯ Object.write node:internal/deps/undici/undici:6327:18
❯ _resume node:internal/deps/undici/undici:8027:54
❯ resume node:internal/deps/undici/undici:7963:7
❯ Client. node:internal/deps/undici/undici:7750:35
❯ connect node:internal/deps/undici/undici:7950:22

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6218:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5858:34
❯ null. wasm:/wasm/0002f80e:1:26723
❯ Parser.execute node:internal/deps/undici/undici:5971:26
❯ Parser.readMore node:internal/deps/undici/undici:5950:16
❯ Socket. node:internal/deps/undici/undici:6278:18
❯ Socket.emit node:events:513:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ writeH1 node:internal/deps/undici/undici:6492:30
❯ Object.write node:internal/deps/undici/undici:6327:18
❯ _resume node:internal/deps/undici/undici:8027:54
❯ resume node:internal/deps/undici/undici:7963:7
❯ Client. node:internal/deps/undici/undici:7750:35
❯ connect node:internal/deps/undici/undici:7950:22

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6218:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5858:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5971:26
❯ Parser.readMore node:internal/deps/undici/undici:5950:16
❯ Socket. node:internal/deps/undici/undici:6278:18
❯ Socket.emit node:events:513:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ writeH1 node:internal/deps/undici/undici:6492:30
❯ Object.write node:internal/deps/undici/undici:6327:18
❯ _resume node:internal/deps/undici/undici:8027:54
❯ resume node:internal/deps/undici/undici:7963:7
❯ Client. node:internal/deps/undici/undici:7750:35
❯ Client.[dispatch] node:internal/deps/undici/undici:7791:24
❯ Client.Intercept node:internal/deps/undici/undici:7517:20
❯ Client.dispatch node:internal/deps/undici/undici:588:44

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6218:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5858:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5971:26
❯ Parser.readMore node:internal/deps/undici/undici:5950:16
❯ Socket. node:internal/deps/undici/undici:6278:18
❯ Socket.emit node:events:513:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ writeH1 node:internal/deps/undici/undici:6492:30
❯ Object.write node:internal/deps/undici/undici:6327:18
❯ _resume node:internal/deps/undici/undici:8027:54
❯ resume node:internal/deps/undici/undici:7963:7
❯ Client. node:internal/deps/undici/undici:7750:35
❯ Client.[dispatch] node:internal/deps/undici/undici:7791:24
❯ Client.Intercept node:internal/deps/undici/undici:7517:20
❯ Client.dispatch node:internal/deps/undici/undici:588:44

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6218:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5858:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5971:26
❯ Parser.readMore node:internal/deps/undici/undici:5950:16
❯ Socket. node:internal/deps/undici/undici:6278:18
❯ Socket.emit node:events:513:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ writeH1 node:internal/deps/undici/undici:6492:30
❯ Object.write node:internal/deps/undici/undici:6327:18
❯ _resume node:internal/deps/undici/undici:8027:54
❯ resume node:internal/deps/undici/undici:7963:7
❯ Client. node:internal/deps/undici/undici:7750:35
❯ Client.[dispatch] node:internal/deps/undici/undici:7791:24
❯ Client.Intercept node:internal/deps/undici/undici:7517:20
❯ Client.dispatch node:internal/deps/undici/undici:588:44

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.

[failure] 180-180: Unhandled error
TypeError: Cannot read properties of undefined (reading 'opaque')
❯ onMessage test/diagnostics_channel.test.ts:180:28
❯ Channel.publish node:diagnostics_channel:150:9
❯ Request.onComplete node:internal/deps/undici/undici:2077:29
❯ Parser.onMessageComplete node:internal/deps/undici/undici:6218:17
❯ wasm_on_message_complete node:internal/deps/undici/undici:5858:34
❯ null. wasm:/wasm/0002f80e:1:6425
❯ Parser.execute node:internal/deps/undici/undici:5971:26
❯ Parser.readMore node:internal/deps/undici/undici:5950:16
❯ Socket. node:internal/deps/undici/undici:6278:18
❯ Socket.emit node:events:513:28

This error originated in "test/diagnostics_channel.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should support trace request by urllib:request and urllib:response". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • If the error occurred after the test had been completed, this was the last documented test before it was thrown.
🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)
test/diagnostics_channel.test.ts

[failure] 224-224: test/diagnostics_channel.test.ts > diagnostics_channel.test.ts > should support trace socket info with H2 by undici:client:sendHeaders and undici:request:trailers
AssertionError: undefined == true
❯ test/diagnostics_channel.test.ts:224:5

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18.19.0)
test/diagnostics_channel.test.ts

[failure] 224-224: test/diagnostics_channel.test.ts > diagnostics_channel.test.ts > should support trace socket info with H2 by undici:client:sendHeaders and undici:request:trailers
AssertionError: undefined == true
❯ test/diagnostics_channel.test.ts:224:5

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)
test/diagnostics_channel.test.ts

[failure] 224-224: test/diagnostics_channel.test.ts > diagnostics_channel.test.ts > should support trace socket info with H2 by undici:client:sendHeaders and undici:request:trailers
AssertionError: undefined == true
❯ test/diagnostics_channel.test.ts:224:5

🪛 GitHub Check: Node.js / Test (macos-latest, 18.19.0)
test/diagnostics_channel.test.ts

[failure] 224-224: test/diagnostics_channel.test.ts > diagnostics_channel.test.ts > should support trace socket info with H2 by undici:client:sendHeaders and undici:request:trailers
AssertionError: undefined == true
❯ test/diagnostics_channel.test.ts:224:5

🪛 GitHub Check: Node.js / Test (macos-latest, 18)
test/diagnostics_channel.test.ts

[failure] 224-224: test/diagnostics_channel.test.ts > diagnostics_channel.test.ts > should support trace socket info with H2 by undici:client:sendHeaders and undici:request:trailers
AssertionError: undefined == true
❯ test/diagnostics_channel.test.ts:224:5

🔇 Additional comments (2)
src/utils.ts (1)

175-177: LGTM

The addition correctly checks for the existence of autoSelectFamilyAttemptedAddresses and assigns it to socketInfo.

src/HttpClient.ts (1)

683-684: LGTM

Including res.socket in the debug logging enhances diagnostic capabilities and helps in tracing socket-related issues.

test/diagnostics_channel.test.ts Show resolved Hide resolved
@@ -50,7 +50,7 @@
"mime-types": "^2.1.35",
"qs": "^6.12.1",
"type-fest": "^4.20.1",
"undici": "^7.0.0",
"undici": "^7.1.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.66%. Comparing base (503dbd8) to head (59a319f).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #553      +/-   ##
==========================================
- Coverage   95.82%   95.66%   -0.16%     
==========================================
  Files          11       11              
  Lines        1270     1270              
  Branches      307      306       -1     
==========================================
- Hits         1217     1215       -2     
- Misses         49       51       +2     
  Partials        4        4              

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

@fengmk2 fengmk2 merged commit bd19f6d into master Dec 17, 2024
26 of 27 checks passed
@fengmk2 fengmk2 deleted the test-sendHeaders branch December 17, 2024 01:34
fengmk2 pushed a commit that referenced this pull request Dec 17, 2024
[skip ci]

## [4.6.9](v4.6.8...v4.6.9) (2024-12-17)

### Bug Fixes

* should got undici:client:sendHeaders message on H2 ([#553](#553)) ([bd19f6d](bd19f6d))
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.

http/2 agent 下会丢失 undici:client:sendHeaders 事件
1 participant