A hung page (a runaway Runtime.evaluate, a synchronous DOM op) holds the process-wide V8 lock and wedges every other session forever. The one-shot CLI has a process-level hard deadline for this; the long-running server cannot force-exit, so terminate just the offending isolate instead. dispatch() arms a watchdog on the session page's isolate after taking the V8 lock and disarms it after the handler; on overrun it terminates the isolate and clears the termination flag so the session keeps working. OBSCURA_CDP_COMMAND_TIMEOUT_MS tunes the bound (default 60s, 0 disables); navigation already self-bounds well under it. The watchdog is a single long-lived shared thread (cdp_watchdog), not a thread per command: the V8 lock serializes commands so at most one is ever armed, and arm/disarm are a mutex plus notify with no measurable per-command cost. Also fixes a lost-wakeup in the per-call watchdog (spawn_watchdog) where disarming a fast call before the watchdog thread started blocked for the full budget. Verified: a hung Runtime.evaluate is terminated at the budget and the session recovers; CDP integration 37/37, obstacle course 33/33; per-command latency unchanged (watchdog on equals off within noise).
14 lines
238 B
Rust
14 lines
238 B
Rust
#[macro_use]
|
|
extern crate html5ever;
|
|
|
|
pub mod cdp_watchdog;
|
|
pub mod module_loader;
|
|
pub mod runtime;
|
|
pub mod ops;
|
|
pub mod v8_flags;
|
|
pub mod v8_lock;
|
|
pub mod markdown;
|
|
|
|
pub use markdown::HTML_TO_MARKDOWN_JS;
|
|
pub use v8_flags::set_v8_flags;
|