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.

@shmishra99
Copy link
Collaborator

@vachmara, Thank you for raising this PR. I have created an internal bug for the review.

@shmishra99 shmishra99 added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Jan 20, 2026
@vachmara vachmara requested a review from hkt74 January 23, 2026 11:04
Copy link
Collaborator

@hkt74 hkt74 left a comment

Choose a reason for hiding this comment

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

Thanks for resolve the last comments quickly, I did a second review using Gemini

@vachmara vachmara requested a review from hkt74 January 27, 2026 09:29
@vachmara
Copy link
Author

Thanks for resolve the last comments quickly, I did a second review using Gemini

Perfect, thank you! Let me know if you need anything else

Copy link
Collaborator

@hkt74 hkt74 left a comment

Choose a reason for hiding this comment

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

I did more tests locally with your change and triggered the github actions

  1. Need to add 'undici' in rollup.config.mjs - externalDeps
  2. fix the github actions

@vachmara
Copy link
Author

Not sure the coverage CI is related to this change, is everything still okay?

@vachmara vachmara requested a review from hkt74 January 27, 2026 23:23
Copy link
Collaborator

@hkt74 hkt74 left a comment

Choose a reason for hiding this comment

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

could the coverage CI related to the change in the package.json file?

/home/runner/work/js-genai/js-genai/dist/src/cross/sentencepiece/sentencepiece_model.pb.js

@vachmara
Copy link
Author

I’ve fixed the test and the discrepancies you flagged, but I still can’t get the coverage CI to run properly

image

@hkt74
Copy link
Collaborator

hkt74 commented Jan 29, 2026

@vachmara I will take a look coverage test

@hkt74
Copy link
Collaborator

hkt74 commented Jan 29, 2026

looks like the coverage test is failing for other pr as well, I think we can skip it for now

@vachmara
Copy link
Author

Perfect, thanks for addressing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:gemini-api ready to pull type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

timeout (server timeout) option isn't work.

3 participants