You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
reflex run --json: worker import errors reach stderr as a plain-text traceback #7196
With reflex run --json, a backend worker that crashes while it imports the app writes a plain-text Python traceback to stderr. A consumer that parses stderr as JSON lines fails on it.
The traceback does not come from a logger. multiprocessing prints it from the Granian worker process, so a Granian logging config cannot format it.
Follow-up to #6972 / #7193. That work makes every stdout line a JSON record. This issue is about stderr only.
To Reproduce
reflex init --template blank
reflex run --json --loglevel debug > out 2> err
# after startup, append this line to the app module and save:
# raise RuntimeError("boom")
err then contains one JSON record followed by plain text:
{"level": "error", "logger": "_granian", "message": "Unexpected exit from worker-1", ...}
Process granian-worker:
Traceback (most recent call last):
File ".../multiprocessing/process.py", line 320, in _bootstrap
self.run()
...
File ".../granian/_internal.py", line 47, in load_module
__import__(module_name)
File ".../app/app.py", line 59, in <module>
raise RuntimeError("boom")
RuntimeError: boom
Expected behavior
In JSON mode, the worker import error is one JSON record on stderr, with the traceback in the exception field, as JsonHandler does for other records with exc_info.
Notes
Dev mode: reflex already controls the worker target for hot reload in reflex/utils/exec.py, so the import error can be caught there and logged with logger.exception.
Prod mode: Granian spawns the worker itself. Reflex has no hook there today.
The behavior is the same without --json, where plain text is correct. Only JSON mode needs the change.
Activity
linear-code commentedon Sep 18, 2026
ENG-12522
fix: emit every output line as JSON in reflex run --json (#7350)