Skip to content

Revert requestTermination change#6626

Open
erikcorry wants to merge 3 commits intomainfrom
erikcorry/revert-request-termination
Open

Revert requestTermination change#6626
erikcorry wants to merge 3 commits intomainfrom
erikcorry/revert-request-termination

Conversation

@erikcorry
Copy link
Copy Markdown
Contributor

A better solution was found in the form of https://chromium-review.googlesource.com/c/v8/v8/+/7734848 and so this interface is unused.

@erikcorry erikcorry requested review from a team as code owners April 21, 2026 06:53
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

This PR reverts the requestTermination / isTerminationRequested mechanism from the C++ JSG layer, but the Rust FFI layer still depends on those removed methods.

Issues (by severity)

  1. Build break (high): The Rust FFI layer in src/rust/jsg/ has active callers of the removed IsolateBase::requestTermination() and IsolateBase::isTerminationRequested() methods. These files need corresponding changes:

    • src/rust/jsg/ffi.c++:1089-1095isolate_request_termination() and isolate_is_termination_requested() call the removed methods
    • src/rust/jsg/ffi.h:343-344 — declares those FFI functions
    • src/rust/jsg/v8.rs:555-556 — Rust-side FFI declarations
    • src/rust/jsg/lib.rs:599-623Lock::request_termination() and Lock::is_termination_requested() public methods
    • src/rust/jsg/lib.rs:819catch_panic() calls lock.request_termination() after converting a Rust panic to a JS exception
    • src/rust/jsg-test/tests/resource_callback.rs:441-488 — test that asserts on is_termination_requested()

    The catch_panic case is particularly important: it's the Rust panic handler that terminates the isolate after a panic to prevent GC from observing partially-mutated state. This needs a replacement — likely switching to terminateExecution() (which is still available on IsolateBase) instead of the removed requestTermination(). The is_termination_requested() check in the test would need a different assertion strategy since there's no longer a flag to query.

Comment thread src/workerd/jsg/setup.h
// threads, without holding the lock.
// Immediately cancels JavaScript execution in this isolate, causing an uncatchable exception to
// be thrown. Safe to call across threads, without holding the lock.
void terminateExecution() const;
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.

The C++ side is fine, but the Rust FFI layer still calls requestTermination() and isTerminationRequested() which no longer exist:

  • src/rust/jsg/ffi.c++:1089-1095 — will fail to compile
  • src/rust/jsg/lib.rs:819catch_panic() calls lock.request_termination() to terminate the isolate after a Rust panic, preventing GC from observing partially-mutated state. This is an important safety mechanism that needs a replacement (probably terminateExecution()).
  • src/rust/jsg-test/tests/resource_callback.rs — test asserts on is_termination_requested()

These all need to be updated as part of this revert.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 21, 2026

Review posted successfully on PR #6626. Here's a summary:

High-severity issue found: The PR removes requestTermination() and isTerminationRequested() from the C++ IsolateBase and Lock classes, but the Rust FFI layer in src/rust/jsg/ still actively calls both methods across 6 files:

  • FFI bridge (ffi.c++, ffi.h, v8.rs) — will fail to compile
  • Lock wrapper (lib.rs) — exposes request_termination() and is_termination_requested() to Rust code
  • Panic handler (lib.rs:819) — catch_panic() calls request_termination() to safely terminate the isolate after a Rust panic, preventing GC from observing partially-mutated state. This is a safety-critical path that needs a replacement.
  • Test (resource_callback.rs) — asserts on is_termination_requested()

github run

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

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.

2 participants