Skip to content

fix(performance): retry failed CPU and FPS closes instead of blocking new sessions - #67

Merged
lauridskern merged 2 commits into
mainfrom
fix/performance-close-retry
Oct 29, 2026
Merged

lauridskern merged 2 commits into
mainfrom
fix/performance-close-retry

Conversation

@lauridskern

@lauridskern lauridskern commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

If a CPU or Display FPS session close failed, the panel's cleanup promise stayed rejected for good. Retry, device switches and reconnects then failed without opening a new session.

Now stop() waits for earlier work with Promise.allSettled, keeps a cleanup promise that never rejects, and still reports its own close failure so the panel shows it. A session stays owned until its close succeeds. That includes a session that finishes opening after a stop or device switch. Before either panel opens another collector, it closes any session it still owns. A failed close stays visible and blocks the new session until a later retry succeeds, so collectors never overlap. FPS retry() and device selection wait on their own stop, like CPU restart(). Each action makes one close attempt.

Tests, with a mock host:

  • A failed close is shown, then retried before the next open, for CPU, FPS and FPS show().
  • A delayed open, then a stop or device switch, a failed late close, then host recovery and retry.

The new tests fail before the fix. node --test "packages/ui/test/*.test.ts" "packages/shared/test/*.test.ts": 428 passed.

Telemetry is unchanged. The UI tool-call wrapper records a span and outcome for every close attempt, retries included, and reports failures with captureUiError.

… new sessions

A close failure during stop left the panel's cleanup promise rejected
forever, so retry, device selection and reconnects never opened another
session. Cleanup now waits for prior work with allSettled and reports only
the current stop's failure. A session stays current until its close
succeeds, so the next stop or open retries the close before starting
another collector.
When a stop or device switch happened during session creation, the late
session was closed once and dropped if that close failed. The panel now
owns the session as soon as it opens, and both panels close any session
they still own before opening another collector.
@lauridskern
lauridskern marked this pull request as ready for review October 29, 2026 15:00
@lauridskern
lauridskern merged commit 309985d into main Oct 29, 2026
12 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.

1 participant