Skip to content

fix(state): forward @change listener exceptions to on_exception - #105

Merged
jourdain merged 3 commits into
masterfrom
fix-change-exception-handling
Nov 11, 2026
Merged

jourdain merged 3 commits into
masterfrom
fix-change-exception-handling

Conversation

@jourdain

Copy link
Copy Markdown
Collaborator

Exceptions raised by @change listeners were only logged as a warning, and exceptions from async listeners never went through the state at all. They are now reported to the server's controller.on_exception (i.e. @life_cycle.exception), the same place RPC exceptions already go.

  • State accepts an exception_handler; child states use the root's handler
  • async listener tasks report their exception when they finish
  • fall back to the previous warning, now with a traceback, when no on_exception is registered or the handler fails
  • server state and context forward to the root controller.on_exception
  • example: add a change listener that raises
  • docs(readme): add development setup instructions

Exceptions raised by @change listeners were only logged as a warning, and
exceptions from async listeners never went through the state at all. They
are now reported to the server's controller.on_exception (i.e.
@life_cycle.exception), the same place RPC exceptions already go.

- State accepts an exception_handler; child states use the root's handler
- async listener tasks report their exception when they finish
- fall back to the previous warning, now with a traceback, when no
  on_exception is registered or the handler fails
- server state and context forward to the root controller.on_exception
- example: add a change listener that raises
- docs(readme): add development setup instructions
Coroutines registered with ctrl.xxx.add_task() run as detached tasks, so
when they fail the error was only logged and never reached
controller.on_exception (i.e. @life_cycle.exception). They are now
reported there, like @change listener exceptions.

- Controller accepts an exception_handler; child controllers use the
  root's handler
- fall back to logging with a traceback when no on_exception is
  registered or the handler fails
- failures of on_exception's own tasks are only logged to avoid loops
- docs(readme): list change listeners and controller tasks under
  on_exception
Newer pytest-asyncio warns when this option is unset, and
filterwarnings = ["error"] turns that warning into a startup failure.
@jourdain
jourdain merged commit 6d928ef into master Nov 11, 2026
11 checks passed
@jourdain
jourdain deleted the fix-change-exception-handling branch November 11, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant