[codex] Add per-probe runtime deadline#500
Conversation
|
Stack note for maintainers/agents: Recommended #487 merge order:
This PR is based on Remaining follow-up candidates after this stack: shared timeout wrapper for remaining host subprocess calls, bounded local HTTP API accept path, cache-write debounce, and lightweight probe diagnostics. #490 is separate from this stack and can merge anytime. |
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR adds a per-probe wall-clock deadline (default 30s) to prevent plugin probes from running indefinitely. It enforces the deadline both for CPU-bound QuickJS execution (via the QuickJS interrupt handler) and for blocking host API calls by clamping host.http and host.ccusage timeouts to the remaining probe budget, while preserving the existing “Error badge on failure” output contract.
Changes:
- Introduce a 30s probe budget and QuickJS interrupt-based cancellation for CPU-bound scripts.
- Propagate a
ProbeDeadlineinto the host API and clamp HTTP/ccusage timeouts to remaining budget. - Add targeted tests for CPU-bound timeout behavior and host timeout clamping.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src-tauri/src/plugin_engine/runtime.rs |
Adds per-probe timeout orchestration and QuickJS interrupt handling; returns a consistent timeout error badge. |
src-tauri/src/plugin_engine/host_api.rs |
Introduces ProbeDeadline and clamps host.http / host.ccusage timeouts to the remaining probe budget; adds deadline-related tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
d5eeb2f to
767394b
Compare
|
Addressed the review feedback in the latest push:
Verified locally with |
Summary
host.httpandhost.ccusageWhy
This is another small slice of #487. Previous follow-ups limit duplicate auto-update probes and batch fan-out; this one bounds the duration of an individual provider probe for the highest-risk paths: CPU-bound JavaScript loops and the existing long-running HTTP/ccusage calls.
The timeout is intentionally conservative at 30 seconds per provider. Existing provider-level HTTP defaults and ccusage timeouts continue to work, but they cannot exceed the remaining per-probe budget.
Scope and limitations
This is not a complete hard deadline for every possible host API path yet. It does not rewrite every synchronous local operation into a killable subprocess helper. In particular, local filesystem operations and the remaining system-command based helpers (
security,sqlite3,ps,lsof, plus env shell reads) are left for a later, more invasive slice.That follow-up is called out separately so this PR stays small and reviewable: first stop CPU-bound plugin scripts and clamp the known long-running HTTP/ccusage calls, then add a shared timeout wrapper for the remaining host subprocess helpers.
This does not change frontend scheduling, event names, provider enablement, or manual refresh behavior.
Validation
bun run bundle:pluginscargo test plugin_engine::runtime::testscargo test plugin_engine::host_api::tests::probe_deadline_clamps_host_timeout_to_remaining_budgetcargo test plugin_engine::host_api::tests::ccusage_timeout_stops_runner_fallbackcargo test plugin_engine::host_api::tests::ccusage_runner_retries_legacy_package_when_current_package_failscargo test --lib -- --skip ccusage_timeout_kills_descendant_and_closes_pipesbun run buildnode ./node_modules/vitest/vitest.mjs runI also ran full
cargo test; Rust compilation and 97 tests passed, but the existingccusage_timeout_kills_descendant_and_closes_pipestest still fails locally while trying to readdescendant.pidbefore it exists. I did not change that unrelated test in this PR. That test is handled separately in #501.Part of #487.