Skip to content

Prevent system theme sync from crashing after Pi reloads - #3

Open
GodGardensGuns wants to merge 1 commit into
ferologics:mainfrom
GodGardensGuns:fix-stale-context-after-session-shutdown
Open

Prevent system theme sync from crashing after Pi reloads#3
GodGardensGuns wants to merge 1 commit into
ferologics:mainfrom
GodGardensGuns:fix-stale-context-after-session-shutdown

Conversation

@GodGardensGuns

Copy link
Copy Markdown

Issue

Pi now marks extension contexts as stale after session replacement or reload. pi-system-theme keeps a polling interval that captures the ctx from session_start. If Pi reloads, forks, switches sessions, or otherwise shuts down the current extension runtime while an appearance detection poll is in flight, that async poll can resume later and access ctx.ui.

That raises:

Error: This extension ctx is stale after session replacement or reload.

In interactive mode this can crash Pi via an uncaught exception.

Fix

  • track the active session with a per-session token
  • clear polling and invalidate the token on session_shutdown
  • re-check the token after async appearance detection before reading or writing ctx.ui
  • keep /system-theme save/apply behavior guarded against stale sessions as well

Testing

  • npx --yes vitest run

Also added a regression test that simulates shutdown while appearance detection is in flight and verifies the stale ctx.ui is not accessed.

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