fix(core): add timeout to tree-sitter initialization to prevent hanging#24970
fix(core): add timeout to tree-sitter initialization to prevent hanging#24970spencer426 wants to merge 1 commit intomainfrom
Conversation
Summary of ChangesHello, 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 improves the robustness of shell parser initialization and process execution. By implementing timeouts and explicit state tracking for Tree-Sitter, it prevents potential memory leaks and hangs. Additionally, it ensures reliable resource cleanup for spawned processes by wrapping execution logic in try...finally blocks. Highlights
Using Gemini Code AssistThe 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
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 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. Footnotes
|
|
Hi @spencer426, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
|
You already have 7 pull requests open. Please work on getting existing PRs merged before opening more. |
There was a problem hiding this comment.
Code Review
This pull request enhances the shell utility functions by introducing a state machine and a 30-second timeout to the shell parser initialization process to prevent hangs. Additionally, it ensures that cleanup logic is consistently executed in both spawnAsync and execStreaming by wrapping the core execution logic in try...finally blocks. I have no feedback to provide.
Summary
Addresses a memory leak where the Tree-Sitter loader Promise could hang indefinitely by adding a robust 30-second timeout and an explicit state variable.
Details
The
treeSitterInitializationPromise inshell-utils.tscould hang indefinitely if the native WASM bindings failed to initialize, leaking the module execution context. The fix wraps it in an aggressive 30000msPromise.racetimeout that rejects safely on failure, uses an explicit state variable instead of relying on the Promise object, and properly clears the timeout on success via a.finally()block so it does not hang the process.This is 3 of 4 atomic PRs split from the monolithic memory leak PR #24963.
Related Issues
Pre-Merge Checklist