pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

`check --watch --report-glean` panics at its first commit: "Transaction has pending todo items"

Open mollydoo opened this issue 1 month ago • 1 comments

Describe the bug

Running pyrefly check with both --watch and --report-glean panics during the initial check, before any file changes, and exits 101. Either flag alone works: check --watch survives the initial check and later edits, and check --report-glean <dir> completes and writes the report.

Reproduction (public repository, no virtualenv, no config changes)

git clone https://github.com/django/djangoproject.com.git
cd djangoproject.com
git checkout 429f26837ac0c4df365669e75141546123f8eaf6
mkdir -p /tmp/glean-out
pyrefly check --watch --report-glean /tmp/glean-out

Output (1.4.0-dev.3):

INFO Watching for files in ...
...
ERROR Thread panicked, shutting down: panicked at pyrefly/lib/state/state.rs:3699:9:
Transaction has pending todo items

The backtrace runs through State::commit_transaction ← IncrementalCheckCommand::check ← run_watch. The report files are written before the panic.

Versions

  • 1.4.0-dev.3: panics (state.rs:3699)
  • 1.3.2: panics (state.rs:3631)
  • 1.2.0: panics (state.rs:3429)

macOS (Apple Silicon).

Controls

  • pyrefly check --report-glean /tmp/glean-out (no --watch): exits 1 with type errors, report written, no panic.
  • pyrefly check --watch (no report flag): no panic through the initial check and a subsequent file edit.
  • A small synthetic project (a few hundred generated modules, with and without a third-party import and a type error) did not reproduce it; the repository above does.

Possible cause

--report-glean appears to set the required level to Require::Everything, and the watch loop's commit_transaction then finds todo items still pending.

Why it matters

A watch process that keeps the Glean report current would let a tool rewrite only the changed modules' output instead of re-running a full report after each edit.

mollydoo avatar Oct 04 '26 09:10 mollydoo

Thanks for the thorough report and repro steps!

Some context: --watch is really just an early (under-maintained) experiment with incremental checks in the foreground CLI (the --help text is explicit about its experimental nature). It was never designed to work in combination with any of the --report flags. I also think there's a high likelihood this style of UI gets deprecated in the future in favor of a daemon mode.

So on fixing this: if the fix turns out to be easy, we're happy to take a PR. Otherwise I'm a bit inclined to leave this combination unsupported rather than invest in making an experimental flag compose with the report pipeline.

grievejia avatar Oct 04 '26 17:10 grievejia