Skip to content

Conversation

@vachmara
Copy link

@vachmara vachmara commented Dec 27, 2025

Fix #712

This pull request updates how the undici HTTP client library is managed and integrated in the project, moving it from a direct dependency to a peer dependency, and adds improved Node.js HTTP timeout handling using undici's Agent. It also introduces corresponding test coverage for this new behavior.

Dependency management:

  • Put undici and undici-types to peerDependencies in package.json, and marked them as optional in peerDependenciesMeta. This makes them optional peer dependencies instead of always-installed direct dependencies.

Node.js HTTP request improvements:

  • In src/_api_client.ts, updated the request logic to dynamically import undici and set a custom Agent with timeout options for Node.js environments, improving HTTP timeout handling.

Testing:

  • Added a new unit test in test/unit/api_client_test.ts to verify that the dispatcher with timeouts is set on HTTP requests in Node.js, and imported the required Agent and types from undici for testing.

Shout out to @yulisunny for spotting the issue, I tested this on vercel it's working!

@google-cla
Copy link

google-cla bot commented Dec 27, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

timeout (server timeout) option isn't work.

1 participant