Skip to content

fix(rt): support fake time in legacy client and TokioTimer#1064

Merged
0x676e67 merged 3 commits intomainfrom
fix
Feb 13, 2026
Merged

fix(rt): support fake time in legacy client and TokioTimer#1064
0x676e67 merged 3 commits intomainfrom
fix

Conversation

@0x676e67
Copy link
Owner

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @0x676e67, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the hyper-util client's connection pool by integrating support for 'fake time'. This change allows the idle timeout and expiration logic to be tested more reliably in environments where time progression is controlled, significantly improving the robustness and predictability of time-sensitive operations within the client.

Highlights

  • Fake Time Support: Introduced a mechanism to allow the connection pool's idle timeout logic to operate correctly with 'fake time' provided by testing utilities like tokio::test(start_paused = true).
  • Time Abstraction: Replaced direct calls to Instant::now() with an abstracted now() method within PoolInner and passed current time as a parameter to IdlePopper::pop and Expiration::expires.
  • Testability Improvements: Refactored existing tests and added new ones specifically for 'faketime' scenarios, ensuring the connection pool behaves as expected under time-manipulated environments.
Changelog
  • src/client/http/client/pool.rs
    • Modified IdlePopper::pop to accept a now parameter for current time.
    • Updated Expiration::expires to accept a now parameter for time calculations.
    • Added a now() method to PoolInner to abstract current time retrieval, using the timer's now() if available, otherwise Instant::now().
    • Replaced direct Instant::now() calls with the new now parameter or self.now() in IdlePopper, PoolInner, Checkout, and IdleTask.
    • Refactored the test_pool_timer_removes_expired test into an inner helper function and added separate tests for real-time and fake-time scenarios.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a backport that adds support for fake time in the legacy client and TokioTimer. The changes primarily involve abstracting away direct calls to Instant::now() and replacing them with a timer abstraction that can provide a mocked now() in test environments. This is achieved by introducing a now() method on PoolInner and updating various parts of the connection pool logic to use it, including connection expiration checks and idle timestamping. The changes are consistent, well-contained, and improve the testability of the connection pool. The addition of tests that run under both real and fake time confirms the correctness of the implementation. The code quality is high, and I have no specific comments for improvement on the changes presented.

@0x676e67 0x676e67 merged commit 29acebc into main Feb 13, 2026
22 checks passed
@0x676e67 0x676e67 deleted the fix branch February 13, 2026 13:26
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.

1 participant

Comments