Silent app exit: unhandled exceptions in callbacks / background threads are never logged (desktop 0.86.x)

Aperta Adatta ai principianti
#7,102 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
62/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia dalla documentazione sulla gestione degli errori e dalla sezione del cookbook 1.0 su page.run_task() menzionata nell’issue. Controlla come quella documentazione descrive le eccezioni nei callback e nei thread in background, quindi documenta la configurazione supportata dell’hook globale oppure chiarisci il comportamento di Flet in questi casi. Il lavoro è completato quando la documentazione sulla gestione degli errori spiega cosa viene registrato e come gli utenti possono acquisire le eccezioni non gestite.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Split out of #7100 so it can be tracked independently.

Environment

  • Flet 0.86.5, Python 3.14, Windows 11
  • Packaged as a single desktop executable (no console attached)
  • The app uses long-lived background workers and timer-driven UI updates

Observed behaviour

A packaged build occasionally exited with nothing shown to the user. The last
line in the application log was:

20:12:12 Session was garbage collected

followed by silence: no on_disconnect, no shutdown record, no traceback.
Try/except around individual event handlers did not capture the failure.

Diagnosis

The exception was raised in a Flet event callback or in a background thread,
outside the code path covered by the application's normal logging. With no
console attached, Python's default handling produced nothing useful.

Installing three hooks at startup made the next failure fully visible:

  • sys.excepthook
  • threading.excepthook
  • asyncio.get_running_loop().set_exception_handler(...)

After that, the next crash produced a complete stack trace in the log. Without
those hooks the failure is effectively invisible, which makes it very hard to
file a useful bug report.

What would help

The 1.0 cookbook now documents that an un-awaited page.run_task() future logs
its exception through Flet. It does not say what happens to exceptions raised in
plain worker threads, or in a callback that is not a coroutine.

Could Flet either:

  1. log unhandled callback / thread exceptions to the console log by default in
    desktop mode, or
  2. document the recommended global-hook setup as the supported pattern?

A short note in the error-handling docs would already save a lot of blind
debugging. Optionally, emitting a pending-exception summary at session
garbage-collection time would make these silent exits reportable.

No project-specific data is included; the log line above is generic.

Lingua principale
Python
Stelle
17.6k
Fork
753
Merge medio
2g 8h
PR unite (30g)
64

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flet-dev/flet

Tutte le issue di flet-dev/flet

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.