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

オープン 初心者向け
#7,102 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
62/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python

調査の方向性

エラー処理のドキュメントと、issueで言及されている page.run_task() に関する1.0 cookbookのセクションから始めます。それらのドキュメントでcallbackとバックグラウンドスレッドの例外がどのように説明されているかを確認し、サポートされているグローバルフックの設定を記載するか、これらの場合のFletの動作を明確にします。エラー処理のドキュメントで、何がログに記録されるか、ユーザーが未処理の例外をどのように捕捉できるかを説明できたら完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
17.6k
フォーク
753
平均マージ
2日 8時間
マージ済み PR(30日)
64

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

flet-dev/flet のほかの issue

flet-dev/flet の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。