Dev blocking monitor: warnings for handlers from installed packages carry no app location and cannot be acted on

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

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

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

  • #7911 @vjymisal0 による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend, devtools

調査の方向性

Read packages/reflex-base/src/reflex_base/event/processor/blocking.py, focusing on _describe_blocking and the warning in _run; check the existing app-location lookup and the blocking-monitor unit tests. Reproduce with a handler whose __module__ is outside the app directory. Done when third-party handler warnings identify their source and show a shorter stack, with tests covering the behavior and app-owned warnings unchanged.

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

説明

enhancement release-train

Problem

The 0.11 dev event-loop blocking monitor (#7672) warns when an event handler blocks the loop past event_loop_blocking_threshold (0.2 s). For handlers that live in a third-party package the warning is accurate but not actionable. With reflex-local-auth 0.5.0, every login prints a ~30-line warning:

Warning: Event handler LoginState.on_submit is blocking the event loop (threshold: 0.200s). Move blocking I/O to a thread pool or use a non-blocking async API.
Blocking stack (most recent call last):
  ... (site-packages frames) ...
  bcrypt.checkpw(...)

bcrypt.checkpw takes 0.27-0.30 s. The warning has no app file or line (the handler is in site-packages), it does not say which package the handler belongs to, and the app developer cannot fix it. In a 38-step test run it was printed 7 times. The only way to silence it is to turn the monitor off for the whole app (event_loop_blocking_threshold=0).

Repro

pip install reflex reflex-local-auth, build the reflex-local-auth demo (register + login pages), reflex run (dev), log in a few times. Each login prints the warning above.

Expected

  • When no frame of the blocking stack is in the app's own code, the warning says so and names the distribution or top-level module the handler comes from, e.g. "Event handler LoginState.on_submit (from package reflex_local_auth) is blocking the event loop ...", and prints a short stack (from the first non-reflex frame) instead of the full one.
  • A way to silence known third-party handlers without disabling detection for the app, for example a config list of module prefixes to ignore, or reporting each third-party handler only once per process.

Fix direction

  • Code: packages/reflex-base/src/reflex_base/event/processor/blocking.py (_describe_blocking, the warning in _run), and packages/reflex-base/src/reflex_base/config.py if a new option is added.
  • Determine "app code" the same way the existing app-location lookup does (the innermost frame under the app's directory); when none is found, derive the owning package from the handler function's __module__.
  • A new config option is public API; if added, document it in docs/advanced_onboarding/configuration.md next to event_loop_blocking_threshold. Reporting third-party handlers once per process needs no new API and may be enough.
  • Non-goals: no change in prod (the monitor is dev-only); no change to warnings for app-owned handlers.
  • Tests: unit tests in the blocking-monitor test module with a handler whose __module__ is outside the app directory.

Not a regression (the monitor is new in 0.11).

主要言語
Python
スター
29k
フォーク
1.8k
平均マージ
3日 5時間
マージ済み PR(30日)
182

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

reflex-dev/reflex のほかの issue

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

似ている issue

Python の issue をもっと見る

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

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