Skip to content

fix(viewer): silence sh's monitor-thread crash report on webview exit - #3011

Merged
vpetersson merged 1 commit into
masterfrom
fix/viewer-sh-bg-exc
Jun 7, 2026
Merged

fix(viewer): silence sh's monitor-thread crash report on webview exit#3011
vpetersson merged 1 commit into
masterfrom
fix/viewer-sh-bg-exc

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Issues Fixed

Sentry event 0c37023f9c8541a6a8ec6bc7b3cbf092 (release 2026.6.2): every AnthiasViewer crash — and even our own SIGTERM during teardown — surfaced as an unhandled SignalException_SIGABRT from sh's daemon monitor thread, despite the failure already being detected and retried by load_browser().

Description

sh's default _bg_exc=True re-raises the child's exit error inside the library's own background thread, where nothing can catch it; Sentry's threading integration then reports it as handled: no. The spawn in _spawn_webview_once now passes _bg_exc=False — safe because the handle is only used via is_alive() / process.stdout / terminate(), never .wait(), so failure detection stays with the existing D-Bus handshake watch and retry loop.

Verified at runtime: with _bg_exc=False a SIGABRT'd child produces zero unhandled thread exceptions while is_alive() still flips to False. A regression assertion in test_load_browser locks the kwargs in.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

🤖 Generated with Claude Code

- Pass _bg_exc=False when spawning AnthiasViewer: sh's default re-raises
  the exit error (e.g. SignalException_SIGABRT on a Qt init crash, or
  SIGTERM from our own teardown) inside its daemon monitor thread,
  where nothing can catch it
- Sentry reported these as unhandled errors even though the handshake
  watch already detects the death and load_browser() already retries
- The handle is only used via is_alive()/process.stdout/terminate(),
  never .wait(), so no exception is silently deferred
- Lock the kwargs in with a regression assertion in test_load_browser

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@vpetersson
vpetersson requested a review from a team as a code owner June 7, 2026 08:30
@vpetersson vpetersson self-assigned this Jun 7, 2026
@vpetersson
vpetersson requested a review from Copilot June 7, 2026 08:30
@sonarqubecloud

sonarqubecloud Bot commented Jun 7, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents sh from re-raising AnthiasViewer child-process exit errors inside sh’s own background monitor thread (which Sentry reports as unhandled) by disabling background exception propagation for the webview spawn, while keeping existing failure detection in the D-Bus handshake/poll loop.

Changes:

  • Pass _bg_exc=False when spawning AnthiasViewer via sh.Command(...)(..., _bg=True, ...) to avoid unhandled monitor-thread exceptions on crash/teardown.
  • Add a regression assertion in test_load_browser to lock in _bg_exc=False (and _bg=True) for the spawn call.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/anthias_viewer/__init__.py Spawns AnthiasViewer with sh background exceptions disabled to avoid unhandled monitor-thread crash reports.
tests/test_viewer.py Adds an assertion that the webview spawn uses _bg_exc=False (and remains a background process).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vpetersson
vpetersson merged commit 8ff0331 into master Jun 7, 2026
10 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.

2 participants