fix(client): report a rejected sidebar sync instead of failing silently

The mount effect calls void sync() at boot and again on every
settings/document-updated replay. sync() runs setPrefs() and then mount(),
so any throw in that chain rejects the promise with no fail() log, no
error strip and no cleanup line: the panel simply never mounts and the
bottom toggle stays dead.

Seen in the wild across plugins: the native right-sidebar registry throws
'sidebarRight: tab kind ... is already registered (extension)', the throw
escapes through a store listener, setPrefs rejects and the whole sidebar
disappears without a single log line. Listener isolation (PR #652) covers
that entry point; this catch keeps every other sync() rejection visible on
the same last-resort strip the mount path already uses.
This commit is contained in:
joyyoung committed 2026-09-17 15:26:26 +08:00
1 parent 1fcf43ccbe
commit e5a8b5faf5
1 file changed
+4 -2
+4 -2
View File
@@ -340,13 +340,15 @@ export function apply(ctx: Context): void {
if (decision?.suspended) unmount()
else mount()
}
void sync()
// setPrefs and mount() run inside sync(); a rejection there would leave
// the sidebar unmounted with a dead toggle as its only symptom.
void sync().catch((error) => { fail('sync', error) })
// Live re-evaluation: the runtime broadcasts settings-document updates
// (the aionui card saves through the same document). Best effort —
// deployments without the 'remote' service fall back to boot-time
// evaluation only.
const remote = ctx.get('remote') as { $on?: (event: string, listener: () => void) => () => void } | undefined
const offRemote = remote?.$on?.('settings/document-updated', () => { void sync() })
const offRemote = remote?.$on?.('settings/document-updated', () => { void sync().catch((error) => { fail('sync', error) }) })
return () => {
disposed = true
offRemote?.()