gemini-cli - ✅(Solved) Fix 5-minute timeouts not being cleared [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#24982Fetched 2026-04-09 08:16:35
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Assignees
Timeline (top)
labeled ×2added_to_project_v2 ×1assigned ×1cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #24968: fix(core): clear 5-minute timeouts in oauth flow to prevent memory leaks

Description (problem / solution / changelog)

Summary

Addresses a memory leak in the OAuth flow where a 5-minute timeout was never cleared upon successful authentication, leaving hanging Promises and Generators.

Details

In packages/core/src/code_assist/oauth2.ts and packages/core/src/utils/oauth-flow.ts, 5-minute timeouts were being created and never cleared upon success. This forced the garbage collector to retain the overarching Generator loop, pending Promises, and AsyncLocalStorage telemetry spans for the full 5 minutes. The fix explicitly tracks the timeout and clears it using a .finally() block.

Related Issues

<!-- Fixes #... -->

Fixes #24982

How to Validate

  1. Start a local OAuth callback server flow to verify the timeout is properly cleared immediately:

    Create a file test-timeout.ts:

    import { startCallbackServer } from './packages/core/src/utils/oauth-flow.ts';
    
    async function runTest() {
      console.log('Starting OAuth callback server with a 5-minute timeout...');
      const { port, response } = startCallbackServer('test-state-123');
      
      const assignedPort = await port;
      console.log(`Server listening on port ${assignedPort}.`);
    
      console.log('Simulating successful browser redirect...');
      await fetch(`http://localhost:${assignedPort}/oauth/callback?code=test-code-abc&state=test-state-123`);
    
      const result = await response;
      console.log('Authentication flow completed successfully with code:', result.code);
      console.log('Script finished. If the bug is fixed, the process will exit IMMEDIATELY.');
    }
    
    runTest().catch(console.error);
  2. Execute the script:

    npx tsx test-timeout.ts
  3. Ensure the script prints the output and exits instantaneously without hanging.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Changed files

  • packages/core/src/code_assist/oauth2.ts (modified, +14/-4)
  • packages/core/src/mcp/oauth-provider.test.ts (modified, +25/-21)
  • packages/core/src/utils/oauth-flow.test.ts (modified, +22/-0)
  • packages/core/src/utils/oauth-flow.ts (modified, +20/-5)

Code Example

> /about
# paste output here
RAW_BUFFERClick to expand / collapse

What happened?

5-minute timeouts are being created and never cleared upon success. This forces the garbage collector to retain the overarching Generator loop, pending Promises, and AsyncLocalStorage telemetry spans for the full 5 minutes.

What did you expect to happen?

Timeouts will be cleared.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
# paste output here
</details>

Login information

No response

Anything else we need to know?

No response

extent analysis

TL;DR

Clearing timeouts upon success is necessary to prevent the garbage collector from retaining unnecessary resources.

Guidance

  • Investigate the timeout creation mechanism to identify why timeouts are not being cleared after a successful operation.
  • Review the code responsible for handling successful operations to ensure that timeout clearance is properly implemented.
  • Consider implementing a timeout clearance mechanism that triggers upon success, to prevent unnecessary resource retention.
  • Verify the effectiveness of any changes by monitoring the garbage collector's behavior and resource retention after successful operations.

Example

No specific code snippet can be provided without more context, but a hypothetical example of clearing a timeout might look like this:

const timeoutId = setTimeout(() => {
  // operation
}, 300000); // 5 minutes

// Upon success, clear the timeout
clearTimeout(timeoutId);

Notes

The exact implementation of the fix will depend on the specifics of the codebase and the timeout creation mechanism, which are not provided in the issue.

Recommendation

Apply a workaround to clear timeouts upon success, as this is a targeted fix that addresses the specific issue described, without requiring additional context or changes to the underlying system.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - ✅(Solved) Fix 5-minute timeouts not being cleared [1 pull requests, 1 participants]