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

Đang mở Phù hợp với người mới
#7,102 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
62/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend, documentation

Hướng nghiên cứu

Bắt đầu với tài liệu xử lý lỗi và phần cookbook 1.0 về page.run_task() được đề cập trong issue. Kiểm tra cách tài liệu đó mô tả các ngoại lệ trong callback và luồng chạy nền, sau đó ghi lại cách thiết lập hook toàn cục được hỗ trợ hoặc làm rõ hành vi của Flet trong những trường hợp đó. Hoàn thành khi tài liệu xử lý lỗi giải thích những gì được ghi nhật ký và cách người dùng có thể bắt các ngoại lệ chưa được xử lý.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
17.6k
Fork
753
Merge trung bình
2 ngày 8 giờ
Pull request đã merge (30 ngày)
64

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flet-dev/flet

Tất cả issue của flet-dev/flet

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.