Skip to content

fix(runtime-environments): don't crash when a server removed via the CLI still responds - #22517

Merged
nwparker merged 3 commits into
stablyai:mainfrom
mmarabel:mmarabel/fix-env-rm-crash-14210
Sep 25, 2026
Merged

nwparker merged 3 commits into
stablyai:mainfrom
mmarabel:mmarabel/fix-env-rm-crash-14210

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

If you deleted a remote server with orca environment rm while the Orca app was open, the app kept talking
to that server. The next message it sent back killed the app — all your windows closed at once.

The app was doing a small piece of housekeeping ("remember when this server was last used") in a place where
nothing was watching for mistakes. Looking up a server that had just been deleted failed, and because nobody
was catching that failure, it took the whole app down with it. Now housekeeping is allowed to quietly fail,
and one message from a server can no longer crash anything.

What Changed

Before: the app crashes (main_uncaught_exception, every window gone) the first time a CLI-removed
server sends anything. It also crashes on the same code path if the settings file is merely unreadable — for
example half-written, or locked by file permissions.

After: the app keeps running. The response is still delivered to whatever asked for it. A line is logged
saying the usage timestamp was skipped.

The mechanism. orca environment rm only edits a file on disk; it never tells the running app, so the
app keeps live sockets to a server it can no longer look up. Every successful response triggers a
lastUsedAt write, and the lookup for that write now throws. Critically, that write is reached from a
WebSocket 'message' callback — there is no promise to reject and no caller to notice, so the throw escapes
into Node's uncaughtException handler, which re-throws it and ends the process.

Two changes, at the two places responsible:

  1. recordRuntimeEnvironmentUsage (new, src/main/ipc/runtime-environment-usage-record.ts) — one named
    main-process boundary that says "usage bookkeeping is advisory here" and swallows any store failure.
    Only the three call sites that cannot report a failure to anyone use it: the two subscription
    onResponse callbacks, and the status owner's verified hook. Awaited request paths keep calling
    markEnvironmentUsed directly and still reject, because there the failure is observable and rejecting is
    the right answer.
  2. A guard in the subscription frame router — handleFrame runs straight off the socket emitter, so it
    now catches a consumer throw and routes it to fail() instead of letting it escape. This mirrors what the
    sibling request router already does, which is exactly why the CLI's identical markEnvironmentUsed call
    was never a crash path. The subscription side was a plain omission.

Why

The first version of this PR added markEnvironmentUsedIfPresent to the shared store: the same function,
suppressing one error. Two problems with that seam.

It fixed one error message, not the crash. The PR's own tests enshrined the rest as intended behaviour
("still surfaces ambiguous selectors and unreadable stores"). A store file that is corrupt, oversized, or
ACL-hardened against the user still threw out of the same unguarded callback and still killed the app. Two
of the tests added here fail on that version.

It put main-process-only policy in a shared module. The store gained two exports with identical
signatures where the correct choice depends on which process you are in — the CLI must stay strict, since
it turns "Unknown environment" into a user-facing error. Nothing encoded that, so the next main-process
caller picks by coin flip. Drawing the line around the caller instead of the error keeps one store
contract and makes the leniency visible in the import path.

Alternative rejected: catching everything inside the shared frame routers. That would hide unrelated
bugs. The guard added here does not swallow — it routes a consumer throw into the existing failure path
(onError + onClose), which is observable, already tested, and identical to the request router.

Scope removed: the earlier version also gated transport.establish() on the environment still existing.
That is dropped. It was a no-op in the very scenario it targeted (pauseStandingRetry returns immediately
while subscriptions exist, and they always do here), it put removal policy in a status reader, and it
collided with #21048, which is doing that teardown properly. The PR body previously claimed this "stops
reconnecting the shared-control channel"; it did not, and that claim is gone.

Sequencing with #21048: the two compose rather than overlap. #21048 owns "a CLI-removed environment loses
its transport." This PR owns "a response that lands before that happens does not kill the app." Either can
merge first; neither needs the other.

Linked Issue

Fixes #22771

Split out of #14210 (side problem 2). The tailnet timeout that is the main subject of #14210 is untouched,
so this deliberately does not close it. Related: #20995 and #21048 cover the other half of this scenario —
tearing the connection down — which is out of scope here.

Visual Proof

N/A. This is main-process logic with no UI surface: nothing renders differently. The only user-visible
difference is the absence of a crash, which is covered by the tests below.

Testing

Reproducing the crash (this is what the tests automate):

  1. Pair the app with a Remote Orca Server; open something that streams from it.
  2. In another shell: orca environment rm <that server>.
  3. Let the server send anything. On main, the app dies with main_uncaught_exception.

Automated, and each one verified to fail when the production change is reverted:

  • src/shared/remote-runtime-subscription-request.test.ts — drives a real WebSocket server through
    subscribeRemoteRuntimeRequest, so a consumer throw travels the genuine fatal route
    (ws.on('message') → handleFrame → consumer). Reverting the guard makes vitest report it as an
    unhandled error, which is main_uncaught_exception in production. This is the surface the earlier tests
    never touched.
  • src/main/ipc/runtime-environment-cli-removal-routing.test.ts — seeds a real temp store, subscribes, then
    removes the environment exactly as the CLI does, on both the direct and support-routed paths. Two further
    cases overwrite the store with invalid JSON, covering the failure class the earlier fix left fatal.
  • src/shared/remote-runtime-subscription-frame-router.test.ts — the router routes a throwing onResponse
    or onBinary to fail().

Platforms: run on macOS (darwin arm64). No platform-specific code is involved — no paths, no shells, no
native modules; the store read/write paths are unchanged. Not exercised against a live Remote Orca Server,
which is why the end-to-end test above uses a real local WebSocket server instead of a mocked callback.

  • I manually tested these changes locally — not against a live Remote Orca Server (no paired host
    available here). Compensated for by the real-WebSocket test above, which exercises the actual fatal
    route rather than a mocked callback.
  • Automated tests added/updated, or explained why not below

Local gate: pnpm tc:node, pnpm tc:cli, oxlint, pnpm run check:code-quality:changed (0 new findings),
and pnpm test across the 71 runtime-environment / remote-runtime / CLI-runtime suites (500 passed,
1 skipped).

AI Disclosure

Original change written with Claude Opus 5.5 in the pi coding agent by @mmarabel. Reworked by @nwparker with
Claude Opus 5.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: no path, shell, or platform-specific code. The Windows-relevant part — the ACL-hardened
    secure-file rewrite behind LAST_USED_PERSIST_INTERVAL_MS — is unchanged, and Windows is the platform most
    likely to hit the permission-denied variant this now survives.
  • Remote/SSH: this path belongs to Remote Orca Server environments; SSH-tunnel environments use the same
    store function and get the same protection. No wire change, so mixed client/host versions are unaffected.
  • Performance: one fewer store read than the earlier version (no separate presence scan), identical to
    main on the success path.
  • Backwards compatibility: no exported store API changed.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…CLI still responds

orca environment rm edits the environment store behind the running app, so the
next ok response on a live socket called markEnvironmentUsed, which threw
'Unknown environment' out of an unguarded socket callback. Main-process callers
now use markEnvironmentUsedIfPresent, which skips a missing environment and
keeps every other store error; the status owner pauses shared control instead
of re-establishing it for a removed server.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

IPC routes now record runtime usage through a helper that logs synchronous errors without rethrowing. Status verification establishes transport based on capability. The remote subscription frame router catches response and binary callback exceptions and reports them through its failure path.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 79862

A concurrent usage update can undo CLI environment removal, so that race should be resolved before merging. A temporary store failure can also leave usage metadata stale for an open subscription.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 79862

A server removed from the saved list can still prompt the running app to reconnect its shared-control channel. The exposure appears limited to a previously paired server, but removal no longer blocks this connection attempt.

Retained concerns

  • Medium · security · observed: Removal from the environment store no longer gates shared-control establishment by an already-created status owner. A capable response can initiate reconnection using retained pairing information after removal; no cleanup triggered by CLI removal was established in the inspected path.
Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is a retained connection attempt for a previously paired environment in the running app; the inspected path does not establish new credentials or cross-environment authority.

Security Findings and Attack Paths

  • inferred — A server retaining its prior pairing can provide a capable status response after CLI removal and cause the retained owner to attempt shared-control reconnection. Successful network reconnection, and whether another component promptly tears it down, were not verified.

Trust Boundaries and Controls

  • observed — The callback guard runs after the frame router's decryption, readiness and response-schema checks. It does not itself create a new path for unvalidated remote frames into subscriber callbacks.

Resilience and Maintainability Implications

  • observed — The usage wrapper isolates response delivery from store errors, including errors other than a missing environment. That failure isolation also removes the store result as a status-transport lifecycle gate.

Hardening Proposals

  • proposed — Keep response bookkeeping non-fatal, but independently invalidate or close retained transport ownership when a saved environment is removed, and check that ownership before a later establishment attempt.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: preventing crashes when a CLI-removed server sends a response.
Description check ✅ Passed The description is complete and focused. It covers the user impact, implementation, rationale, linked issue, testing, platform considerations, scope, and checklist requirements.
  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a5fe37ce-131e-4124-8715-fee670acd58b

📥 Commits

Reviewing files that changed from the base of the PR and between 641a7f3 and 242d5bc.

📒 Files selected for processing (7)
  • src/main/ipc/runtime-environment-removed-environment-routing.test.ts
  • src/main/ipc/runtime-environment-status-owner.ts
  • src/main/ipc/runtime-environment-support-routing.ts
  • src/main/ipc/runtime-environment-transport-routing.ts
  • src/main/ipc/runtime-environments-subscription-lifecycle.test.ts
  • src/shared/runtime-environment-store.test.ts
  • src/shared/runtime-environment-store.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

Comment thread src/shared/runtime-environment-store.ts Resolved

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

✅ No new issues found.

Reviewed changes

  • Non-throwing store write: markEnvironmentUsedIfPresent returns false and leaves the store untouched when the selector is absent, while ambiguous names and unreadable/corrupt stores still throw. markEnvironmentUsed keeps its strict throwing behavior for the CLI.
  • Main-process call sites: transport routing, support routing, and the status owner now record usage through the non-throwing variant, so a successful response from a CLI-removed server can no longer escape a socket callback as an uncaught exception.
  • Shared-control gate: the status owner only calls transport.establish() when the server is still present (capable && present), pausing instead of reviving the channel for a removed server.
  • Tests: new removed-environment routing suite (status verification plus direct and support-routed subscriptions), new store cases, and an existing spy retargeted to the new function.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

nwparker and others added 2 commits September 24, 2026 22:05
…s boundary

Keep one strict store contract and move the leniency to the caller that cannot
report a failure to anyone.

- Revert markEnvironmentUsedIfPresent: drawing the line around one error string
  left corrupt, unreadable and oversized store files still fatal on the same
  unguarded socket callback.
- Add recordRuntimeEnvironmentUsage, a named main-process boundary that says
  lastUsedAt is advisory and swallows every store failure. Route only the three
  sites with no observer through it (subscription onResponse in transport- and
  support-routing, and the status owner's verified hook, where a throw skips
  settleWaiters and hangs refresh callers). Awaited request paths stay strict.
- Guard onResponse/onBinary in the subscription frame router the way the sibling
  request router already guards validateStatus, so no consumer throw can reach
  the ws 'message' emitter and become main_uncaught_exception.
- Drop the status-owner `capable && present` gate: pauseStandingRetry no-ops
  while subscriptions exist, and removal teardown belongs to stablyai#21048's watcher.

Co-authored-by: mmarabel <[email protected]>
…ow escapes

The existing tests invoke the captured onResponse directly, which never touches
the surface that actually kills the app. Drive a real WebSocket server through
subscribeRemoteRuntimeRequest so the throw travels ws 'message' -> handleFrame
-> consumer; without the frame-router guard vitest reports it as an unhandled
error, which is main_uncaught_exception in production.
@nwparker

Copy link
Copy Markdown
Contributor

@mmarabel heads up — @nwparker took this over and pushed two commits directly to your branch rather than
leaving review comments. Your diagnosis was right and the hard part was already done; the rework moves where
the fix sits. Nothing of yours was force-pushed or rewritten.

What changed:

  1. Reverted markEnvironmentUsedIfPresent. src/shared/runtime-environment-store.ts is now
    byte-identical to main. Suppressing one error message left the crash reachable: a corrupt, oversized, or
    ACL-hardened store file still threw out of the same unguarded onResponse and still killed the main
    process. Two of the new tests fail against the previous head for exactly that reason.
  2. Added recordRuntimeEnvironmentUsage (src/main/ipc/runtime-environment-usage-record.ts) — the
    leniency now lives at the main-process boundary instead of in the shared store, so the CLI keeps one
    strict contract and there is no pair of near-identical exports for the next caller to choose wrongly
    between. Only the three call sites with no observer use it; awaited request paths stay strict, which also
    reverts the behaviour change you flagged in your own Review section.
  3. Guarded onResponse/onBinary in the subscription frame router. You were right to reject
    "catch everything in the routers" — but the sibling request router already guards its consumer callback
    and routes a throw to finishError, which is precisely why the CLI's identical markEnvironmentUsed call
    is not a crash path. The subscription side was an omission, not a design choice, so this restores symmetry
    rather than adding defensiveness.
  4. Dropped the status-owner capable && present gate. pauseStandingRetry early-returns while
    subscriptions exist — which they always do in this scenario — so it never touched the socket, and the
    "stops reconnecting the shared-control channel" line in the body was not true against the real code (the
    test asserted it against a vi.fn()). It also collided with fix(runtime-environments): retire transports for CLI-removed environments #21048, which does that teardown properly.
  5. Added a real-WebSocket test. The previous tests invoked the captured onResponse directly, which
    never touches the surface that actually crashes. The new one drives a live local WS server so the throw
    travels ws.on('message') → handleFrame → consumer; revert the guard and vitest reports it as an
    unhandled error.
  6. Renamed the test file to runtime-environment-cli-removal-routing.test.ts, and filed [Bug]: app crashes with main_uncaught_exception when a server removed via orca environment rm sends a response #22771 as a focused
    issue so the PR can Fixes something — Refs #14210 would not have linked, and [Bug]: Remote Orca Server on same tailnet times out at app layer though WebSocket handshake succeeds #14210's main subject
    (the tailnet timeout) is untouched by this.

Every test was verified to fail with its production change reverted. pnpm tc:node, pnpm tc:cli, oxlint,
and check:code-quality:changed are clean; 71 runtime suites pass.

Thanks for the original find and the clear write-up — the crash trace in your description is what made the
rework quick. Sequencing: this PR and #21048 compose cleanly, and neither blocks the other.

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

ℹ️ No code issues — the only note is that the PR description no longer matches the implementation.

Reviewed changes

This run re-reviewed the two commits pushed after the prior pullfrog review (242d5bc2b6), which replaced the store-level markEnvironmentUsedIfPresent fix with a main-process boundary guard.

  • Reverted the store-level fix: markEnvironmentUsedIfPresent and its tests are gone; runtime-environment-store.ts is back to its main shape.
  • Added recordRuntimeEnvironmentUsage: a try/catch wrapper around markEnvironmentUsed that logs and swallows any store failure, now used by the status owner, the direct subscription, and the support-routed subscription.
  • Guarded the subscription frame router: a new deliver(emit) helper converts a consumer-callback throw into a terminal fail() instead of letting it escape the websocket message handler.
  • Reworked the tests: runtime-environment-cli-removal-routing.test.ts replaces the deleted removed-environment suite, and new frame-router plus end-to-end subscription tests prove a consumer throw fails the subscription rather than crashing.

Focused tests pass locally (5 files / 36 tests), and the new coverage is genuine: without the guard the frame-router and integration tests throw out of the handler.

ℹ️ PR description still describes the reverted markEnvironmentUsedIfPresent approach

The description's "What Changed", "After", and "Review" sections describe the store-level variant that these commits removed, so a reviewer reading it would expect code that is not in the diff. In particular it claims the status check "stops reconnecting the shared-control channel for a server that was removed", but the final code revives it.

Technical details
# PR description describes an implementation that is no longer in the diff

## Affected sites
- PR body (`What Changed` / `After` / `Review`) — still says usage is recorded via `markEnvironmentUsedIfPresent`, that a removed server returns `false` and leaves the store untouched, and that request paths now resolve instead of rejecting.
- `src/main/ipc/runtime-environment-status-owner.ts:64` — records through `recordRuntimeEnvironmentUsage`; the `capable && present` gate was dropped, so `transport.establish()` runs whenever `capable` and a removed environment's shared control is revived. The new test asserts `establish` is called once for a removed environment.
- `src/main/ipc/runtime-environment-transport-routing.ts:257` — `markEnvironmentUsedFromResponse` calls the strict `markEnvironmentUsed` again.
- `src/main/ipc/runtime-environment-support-routing.ts:106` — `executeSupportRoutedCall`'s `markUsed` calls the strict `markEnvironmentUsed` again.

## Required outcome
- The description matches the boundary-guard implementation actually in the diff: `recordRuntimeEnvironmentUsage` swallowing store failures on socket callbacks, plus the frame-router `deliver` guard. Either restore the presence gate and keep the removal-teardown claim, or drop that claim from the body.

## Open questions for the human
- Is dropping the presence gate intended? Relative to `main` the behavior is unchanged (the gate only existed in the intermediate commit), but the PR body presents removal teardown as part of the fix.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4143a928-3891-487c-ae1d-b750aa934f67

📥 Commits

Reviewing files that changed from the base of the PR and between 242d5bc and 7986293.

📒 Files selected for processing (8)
  • src/main/ipc/runtime-environment-cli-removal-routing.test.ts
  • src/main/ipc/runtime-environment-status-owner.ts
  • src/main/ipc/runtime-environment-support-routing.ts
  • src/main/ipc/runtime-environment-transport-routing.ts
  • src/main/ipc/runtime-environment-usage-record.ts
  • src/shared/remote-runtime-subscription-frame-router.test.ts
  • src/shared/remote-runtime-subscription-frame-router.ts
  • src/shared/remote-runtime-subscription-request.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

onResponse: (response: RuntimeRpcResponse<unknown>) => {
if (response.ok && shouldMarkUsed()) {
markEnvironmentUsed(args.userDataPath, args.environment.id, {
recordRuntimeEnvironmentUsage(args.userDataPath, args.environment.id, {

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'markedUsed|shouldMarkUsed|recordRuntimeEnvironmentUsage|markUsedOnce' src/main/ipc/runtime-environment-support-routing.ts src/main/ipc/runtime-environment-transport-routing.ts src/main/ipc/runtime-environment-cli-removal-routing.test.ts
sed -n '165,225p' src/main/ipc/runtime-environment-support-routing.ts
sed -n '80,120p' src/main/ipc/runtime-environment-cli-removal-routing.test.ts

Repository: stablyai/orca

Length of output: 5361


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- support routing ---'
sed -n '105,145p' src/main/ipc/runtime-environment-support-routing.ts
sed -n '235,280p' src/main/ipc/runtime-environment-support-routing.ts
printf '%s\n' '--- transport routing ---'
sed -n '180,215p' src/main/ipc/runtime-environment-transport-routing.ts
printf '%s\n' '--- usage record ---'
cat -n src/main/ipc/runtime-environment-usage-record.ts
printf '%s\n' '--- related definitions/tests/docs ---'
rg -n -C 3 'shouldMarkUsed|markUsedOnce|recordRuntimeEnvironmentUsage|lastUsedAt|runtimeId|usage' src/main/ipc src -g '*.ts' -g '*.md' | head -n 300

Repository: stablyai/orca

Length of output: 30451


🏁 Script executed:

set -e
sed -n '115,140p' src/main/ipc/runtime-environment-support-routing.ts
sed -n '250,275p' src/main/ipc/runtime-environment-support-routing.ts
sed -n '188,210p' src/main/ipc/runtime-environment-transport-routing.ts
cat -n src/main/ipc/runtime-environment-usage-record.ts
rg -n -C 3 'shouldMarkUsed|markUsedOnce|recordRuntimeEnvironmentUsage|lastUsedAt|runtimeId' src/main/ipc src -g '*.ts' -g '*.md' | head -n 250

Repository: stablyai/orca

Length of output: 24593


🏁 Script executed:

printf '%s\n' 'support'; sed -n '115,140p' src/main/ipc/runtime-environment-support-routing.ts; printf '%s\n' 'support subscription'; sed -n '255,272p' src/main/ipc/runtime-environment-support-routing.ts; printf '%s\n' 'transport'; sed -n '190,204p' src/main/ipc/runtime-environment-transport-routing.ts; printf '%s\n' 'record'; cat src/main/ipc/runtime-environment-usage-record.ts; printf '%s\n' 'tests'; rg -n -C 4 'recordRuntimeEnvironmentUsage|shouldMarkUsed|markedUsed|lastUsedAt' src/main/ipc -g '*.test.ts' -g '*.ts' | head -n 220

Repository: stablyai/orca

Length of output: 14983


🏁 Script executed:

set -e
rg -n -C 8 'export (async )?function markEnvironmentUsed|export const markEnvironmentUsed|function markEnvironmentUsed' src/shared
rg -n -C 5 'markEnvironmentUsed\(' src/shared src/main -g '*.test.ts' | head -n 180

Repository: stablyai/orca

Length of output: 8060


🏁 Script executed:

sed -n '176,225p' src/shared/runtime-environment-store.ts

Repository: stablyai/orca

Length of output: 1900


Retry usage recording after a failed store operation.

shouldMarkUsed() and markUsedOnce() consume markedUsed before recordRuntimeEnvironmentUsage() can fail. The recorder catches that failure and returns void. A later successful response can therefore skip usage recording while the subscription remains open.

Make recordRuntimeEnvironmentUsage() report whether markEnvironmentUsed() completed without a store error. Set both subscription flags only after that result succeeds. Preserve the existing freshness throttle.

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

Approved to run CI. Taken over and reworked by @nwparker; findings addressed and independently re-verified.

@nwparker
nwparker merged commit 8415031 into stablyai:main Sep 25, 2026
29 checks passed
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.

[Bug]: app crashes with main_uncaught_exception when a server removed via orca environment rm sends a response

2 participants