Skip to content

feat: add support for cancelling build#966

Open
thesayyn wants to merge 1 commit intomainfrom
cancel_build
Open

feat: add support for cancelling build#966
thesayyn wants to merge 1 commit intomainfrom
cancel_build

Conversation

@thesayyn
Copy link
Member

Changes are visible to end-users:yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

Implement ctx.bazel.cancel_invocation() for cancelling previously detached invocation and ctx.build().cancel() for in AXL builds.

Test plan

  • New test cases added

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a84622d108

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@thesayyn thesayyn force-pushed the cancel_build branch 3 times, most recently from d49ac8a to f832370 Compare March 15, 2026 22:51
@thesayyn
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8323703cb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@thesayyn
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ede54c4d9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@thesayyn
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be1d678ae9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Signed-off-by: thesayyn <thesayyn@gmail.com>
@thesayyn
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f5f0359c2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if still_running {
// Get the real bazel client PID from the server.
// If we can't get it, fall back to signalling the wrapper.
let target_pid = super::info::client_pid(None).unwrap_or(wrapper_pid);

Choose a reason for hiding this comment

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

P1 Badge Scope build cancellation to the same Bazel server

build.cancel() looks up both the client PID and server PID with client_pid(None)/server_info(), which always target the default Bazel server, even though ctx.bazel.build() can run with custom startup_flags such as --output_base. In that case, cancel can signal a different in-flight invocation and Cancellation.force() can kill the wrong server while the intended build continues running. The cancellation path should preserve and reuse the build's output-base context (or signal only the spawned child PID).

Useful? React with 👍 / 👎.

}
// Server-wide: poll until the server is no longer busy.
while info::is_server_busy(cancellation.output_base.as_deref()) {
std::thread::sleep(std::time::Duration::from_millis(poll_ms as u64));

Choose a reason for hiding this comment

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

P2 Badge Reject negative poll intervals in cancellation wait

Cancellation.wait() converts poll_ms with poll_ms as u64 before calling Duration::from_millis, so a negative value from Starlark (for example wait(poll_ms = -1)) underflows into a massive sleep interval and effectively hangs the wait loop. Validate or clamp poll_ms to non-negative values before constructing the duration.

Useful? React with 👍 / 👎.

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