Commit 502af73
fix(mpl): contain comm callback errors in mpl_interactive (#9532)
## Summary
A raising callback inside `mpl_interactive._handle_comm_msg` (e.g.
matplotlib's `AttributeError: 'Axes' object has no attribute
'_pan_start'` from `end_pan` without a prior `start_pan`) was
propagating up through `MarimoComm.handle_msg` →
`WIDGET_COMM_MANAGER.receive_comm_message` → the kernel's request
handler, terminating `asyncio.run` and killing the kernel subprocess.
The uvicorn parent kept serving so the UI just reported "stopped
responding".
This wraps the `handle_json` and `_handle_download` calls in `try/except
Exception` and logs via `LOGGER.exception` so a buggy callback is
contained while the traceback still surfaces for diagnosis.
`BaseException` is intentionally not caught.
Fixes the kernel-crash half of the matplotlib pan/zoom issue (see linked
Linear issue). The underlying matplotlib `_pan_start` bug is tracked
separately.
## Test plan
- [x] Manual repro via the linked Linear repro (pan → re-run cell → zoom
→ pan): exception logged, kernel stays alive, figure remains responsive.
- [x] Direct programmatic injection: `_handle_comm_msg` with a raising
`handle_json` returns cleanly and a follow-up message is processed.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent fb38a25 commit 502af73
1 file changed
Lines changed: 26 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
303 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
304 | 313 | | |
305 | 314 | | |
306 | 315 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
319 | 331 | | |
320 | 332 | | |
321 | 333 | | |
| |||
0 commit comments