fix: resolve workspace publish failures and scheduler event loop starvation#28063
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 stability of the nightly release pipeline by ensuring that npm publish commands do not attempt to execute lifecycle scripts. By bypassing these redundant steps, the CI process avoids incorrect environment resolution issues that were causing build failures during package publication. 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 the 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 counterproductive. 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
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request updates the release publishing GitHub action by adding the --ignore-scripts flag to the npm publish commands for the core, CLI, and A2A packages. This prevents lifecycle scripts from running during the publishing process. There are no review comments, and I have no feedback to provide.
Replace queueMicrotask with setTimeout(..., 10) inside _processNextItem loop to allow the event loop's macrotask queue (I/O, timers, child processes) to execute when waiting for external events. Also update parallel tools integration test and mocks.
…ting in CI Add a non-strict option to TestRig.setup to launch the CLI with --fake-responses-non-strict. This allows the integration tests to match mock responses by method name and ignore order differences caused by model-routing (classifier) being active or inactive in different environments (local vs CI).
Summary
This PR resolves two major issues:
--ignore-scriptsflag tonpm publishcommands inside.github/actions/publish-releaseto prevent running redundant package lifecycle scripts (like the rootpreparescript) during workspace publishing in CI.queueMicrotaskyield withsetTimeout(resolve, 10)inScheduler._processNextItem.Details
1. NPM Publish Lifecycle Failures
During nightly releases, when NPM publishes
@google/gemini-cli-corefrom its workspace, it automatically triggers thepreparescript. Because the workspace lacks a separatepreparescript, NPM invokes the root package'spreparescript (husky && npm run bundlewhich runsesbuild.config.js). Since the context has shifted to thecorepackage, the dependencies of@google/gemini-cli(e.g.,dotenv,comment-json,clipboardy) are completely unresolved, causing compilation to fail with 19 errors. Since all packages are already fully built and bundled in preceding CI steps, running these lifecycle scripts on publish is redundant and error-prone. Passing--ignore-scriptssafely prevents them from running and secures a clean release publish.2. Scheduler Event Loop Starvation
running Gemini CLI with parallel tool execution (such as multiple reads/writes in waves) on macOS would completely hang the CLI process. This was caused by the
_processNextItemexecution loop insidepackages/core/src/scheduler/scheduler.tsusingqueueMicrotaskto busy-wait while waiting for active tools or user confirmations. Since microtasks run with priority in the same tick of the event loop, this busy-wait loop completely starved the event loop's macrotask queue (I/O, timers, child processes), preventing the tools from ever dispatching their completion callbacks and deadlocking the CLI at 100% CPU. Replacing this withsetTimeout(resolve, 10)safely yields to the macrotask phase of the event loop, freeing the CPU and allowing React/Ink's render pipeline, standard I/O, and child processes to execute. We also added support for non-strict mock matching (fakeResponsesNonStrict) inTestRigto ensure the integration tests match mock responses correctly whether the model-routing classifier is active (locally) or bypassed (in CI).Related Issues
How to Validate
packages/core/src/scheduler/(149 tests) and integration tests (parallel-tools.test.ts) pass flawlessly.npm run lintandnpm run typecheckrun successfully.Pre-Merge Checklist