Skip to content

fix: resolve workspace publish failures and scheduler event loop starvation#28063

Merged
rmedranollamas merged 4 commits into
google-gemini:mainfrom
rmedranollamas:fix/publish-ignore-scripts
Jun 21, 2026
Merged

fix: resolve workspace publish failures and scheduler event loop starvation#28063
rmedranollamas merged 4 commits into
google-gemini:mainfrom
rmedranollamas:fix/publish-ignore-scripts

Conversation

@rmedranollamas

@rmedranollamas rmedranollamas commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR resolves two major issues:

  1. NPM Publish Lifecycle Failures: Adds the --ignore-scripts flag to npm publish commands inside .github/actions/publish-release to prevent running redundant package lifecycle scripts (like the root prepare script) during workspace publishing in CI.
  2. Scheduler Event Loop Starvation: Fixes an event loop starvation hang on macOS when executing waves of parallel tool calls by replacing the busy-wait queueMicrotask yield with setTimeout(resolve, 10) in Scheduler._processNextItem.

Details

1. NPM Publish Lifecycle Failures

During nightly releases, when NPM publishes @google/gemini-cli-core from its workspace, it automatically triggers the prepare script. Because the workspace lacks a separate prepare script, NPM invokes the root package's prepare script (husky && npm run bundle which runs esbuild.config.js). Since the context has shifted to the core package, 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-scripts safely 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 _processNextItem execution loop inside packages/core/src/scheduler/scheduler.ts using queueMicrotask to 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 with setTimeout(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) in TestRig to 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

  • All unit tests in packages/core/src/scheduler/ (149 tests) and integration tests (parallel-tools.test.ts) pass flawlessly.
  • npm run lint and npm run typecheck run successfully.

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

@rmedranollamas rmedranollamas requested a review from a team as a code owner June 20, 2026 18:28
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • CI Reliability: Added the --ignore-scripts flag to npm publish commands in the release action to prevent unnecessary and failing lifecycle script executions.
  • Build Context Fix: Avoids triggering the root prepare script during workspace publishing, which previously caused compilation errors due to missing dependencies in the sub-package context.
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 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 .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 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

  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.

@github-actions github-actions Bot added the size/xs An extra small PR label Jun 20, 2026
@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 41
  • Additions: +29
  • Deletions: -12
  • Files changed: 5

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

Copy link
Copy Markdown
Contributor

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 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.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Jun 20, 2026
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.
@github-actions github-actions Bot added the size/s A small PR label Jun 21, 2026
…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).
@rmedranollamas rmedranollamas changed the title fix(ci): add --ignore-scripts to npm publish commands fix: resolve workspace publish failures and scheduler event loop starvation Jun 21, 2026
@rmedranollamas rmedranollamas enabled auto-merge June 21, 2026 20:34
@rmedranollamas rmedranollamas added this pull request to the merge queue Jun 21, 2026
Merged via the queue into google-gemini:main with commit be7ba2c Jun 21, 2026
32 checks passed
@rmedranollamas rmedranollamas deleted the fix/publish-ignore-scripts branch June 21, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s A small PR size/xs An extra small PR status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants