Skip to content

fix(hub): ask Windows about toasts on a thread of their own (#398) - #409

Merged
7schmiede merged 1 commit into
mainfrom
fix/398-toast-off-the-runtime
Nov 2, 2026
Merged

7schmiede merged 1 commit into
mainfrom
fix/398-toast-off-the-runtime

Conversation

@7schmiede

Copy link
Copy Markdown
Member

Refs #398. This removes the likeliest cause of the hang. There is still no dump to prove it; the watchdog from #402 will produce one if it happens again.

Why this one:

  • The hub's log of the 0.32.0 hang ends with the forwarded POST …/lanes/<lane>/restart (200). That lane had produced service_failed notices earlier the same day.
  • After a lane restart, the hub's notify::follow_lane reads the lane's new events and calls Center::deliver on a tokio worker.
  • deliver evaluates self.sink.status() (for the shown field) before it writes its notice line. On Windows that is ToastNotificationManager::CreateToastNotifierWithId(..).Setting(), a synchronous call into the notification platform, which is another process.
  • If that call does not return, the worker is held, and so is the task in that worker's LIFO slot, which other workers cannot steal. When that task is the accept loop, the result matches The hub stopped answering and kept its lock: no start could replace it #398: the port stays in Listen, new connections are refused once the backlog is full, accepted connections sit in CloseWait, the process is idle, and nothing more is logged (the notice line never comes).
  • GET /hub/notify and POST /hub/notify/test made the same call on a worker. show already used spawn_blocking.

Change (crates/devstack-desktop/src/windows/notify.rs):

  • One toasts thread makes every WinRT call: the setting, and each toast (with the devstack:// registry check).
  • status() no longer calls Windows. It answers the setting as asked last: at start, every minute, and after each toast.
  • While a call has waited 30 s, status() says Windows' notification platform does not answer. This is told once through hooks.failed, so the log gets notify_failed and the dashboard gets a notice.
  • At most 16 toasts wait; more are dropped until Windows answers again.
  • Linux is unchanged: its sink already answers status() from a cache.

Tests: two new unit tests with a fake platform whose show blocks:

  • show and status still return at once, the sink reports itself stuck once, and the waiting toasts show in order after the call is released.
  • status() is the setting asked last.

cargo clippy and cargo fmt are clean. cargo test -p devstack-desktop -p devstack-hub passes. Not run against a really hanging notification platform.

Docs: CHANGELOG (Fixed). In docs/dashboard-api.md, GET /hub/notify's unavailable now names the new reason, and the doc says the setting may be up to a minute old.

No review card: which thread the toast sink uses is internal. No trust, concept, contract or term changes.

Decided on my own: 30 s until "stuck", a one-minute refresh, a queue of 16.

Not changed, seen on the way: entry() in devstack-hub/src/lib.rs holds the stacks watch read guard while registry::list() reads files (its or_else). It is not a deadlock on its own, but it is the kind of thing to keep short.

🤖 Generated with Claude Code

Before each notification, and for GET /hub/notify, the hub asked
Windows' notification platform for devstack's setting, synchronously on
a tokio worker (`deliver` evaluates `sink.status()` before it logs the
notice). A call into that other process that does not return holds the
worker, and with it the task in its LIFO slot: the accept loop can be
that task, and the hub keeps its port and lock without answering, as in
#398, whose last log line was a lane restart whose lane had notified
before.

The Windows sink now runs every WinRT call (the setting and each toast)
on one thread of its own. `status()` answers the setting as asked last
(again every minute and after each toast), or, while a call has waited
30 s, that Windows does not answer, told once to the hooks
(`notify_failed`). At most 16 toasts wait; more are dropped meanwhile.

Refs #398

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit 7e94c87 into main Nov 2, 2026
@7schmiede
7schmiede deleted the fix/398-toast-off-the-runtime branch November 2, 2026 14:03
@7schmiede 7schmiede mentioned this pull request Nov 2, 2026
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