📚 Correct frontend crash recovery guidance

Remove outdated assumptions about plugin storage and save timing while
keeping diagnostic and unsaved-data precautions.

AI-assisted-by: gpt-6.1-terra
This commit is contained in:
Andrey Antukh 2026-11-24 08:57:29 +00:00
parent f26d466490
commit 8506b916b5
2 changed files with 7 additions and 38 deletions

View File

@ -61,4 +61,4 @@ This is a monorepo. Principles that apply to one module do *not* generally apply
- executing ClojureScript code in the frontend: `mem:frontend/cljs-repl`.
- Failed ClojureScript build or stale hot reload: `mem:frontend/compile-diagnostics`.
- Successful `execute_code` followed by Internal Error: `mem:frontend/handling-crashes` for delayed failures, store inspection and recovery.
- Frontend Internal Error or runtime crash: `mem:frontend/handling-crashes` for store inspection and recovery.

View File

@ -1,38 +1,7 @@
# Frontend Runtime Crash Handling
# Frontend runtime crash recovery
## Detect a runtime workspace crash
Runtime crashes usually show the Internal Error page with title text "Something bad happened" and class `main_ui_static__download-link`. A common pattern is: changes go through via JS API / `execute_code`, then 1-2s later an `update-file` request reaches the backend and is rejected.
After a crash, `execute_code` can become unusable because no plugin instances are connected and any data in its `storage` is lost, but `cljs_repl` usually still works.
Check crash state:
```clojure
(some? (:exception @app.main.store/state))
```
It returns `true` for the store exception page. A React error boundary can show an error without setting this flag; see `mem:frontend/error-reporting`.
## Read the runtime cause
The exception is stored at `(:exception @app.main.store/state)`. Useful keys:
- `:type`, `:code`, `:status`: error class, e.g. `:validation`, `:referential-integrity`, `400`.
- `:hint`, `:details`: human-readable explanation; `:details` often contains validation problems with `:shape-id`, `:page-id`, `:args`, etc.
- `:uri`: API endpoint that returned the error, e.g. `update-file`.
- `:app.main.errors/instance`: underlying JS Error object.
- `:app.main.errors/trace`: JS stack trace string, usually response-handling path rather than the dispatch site that produced the bad change.
```clojure
(let [ex (:exception @app.main.store/state)]
(select-keys ex [:type :code :status :hint :details :uri]))
```
For backend validation errors (`:type :validation`), `:details` is usually the most informative field; it identifies the shape and invariant that failed.
## Recover and continue testing
If `cljs_repl` still works, reload with `(.reload js/location)`; see `mem:frontend/cljs-repl`. Otherwise select the workspace tab by its current URL (`screen=workspace` in the query) and reload that URL. Confirm that the workspace renders again and `(some? (:exception @app.main.store/state))` returns `false`; the store check alone does not detect a React render boundary.
Reload reads the saved version, not unsaved local edits. An earlier commit in a partially rejected save can already be durable; see `mem:frontend/workspace-state-persistence-subtleties` before retrying a sequence of edits.
- For a store exception, inspect `(:exception @app.main.store/state)`: `:type`, `:code`, `:status`, `:hint`, `:details` and `:uri` can identify the failing operation. Validation details can include shape IDs and invariant failures.
- A React error boundary can display an error without setting the store's `:exception`; a nil value alone does not prove the UI recovered. See `mem:frontend/error-reporting`.
- If the live REPL is available, `(.reload js/location)` reloads the browser; otherwise select and reload the workspace tab. Confirm both that the workspace renders and that the store exception is clear. For runtime selection see `mem:frontend/cljs-repl`.
- Before reloading, account for unsaved edits and partial saves: an earlier commit from a rejected batch can already be durable. Review `mem:frontend/workspace-state-persistence-subtleties` before retrying edits.
- `execute_code` waits for save and fails on errors or rollback detected during that wait, but later failures can still occur. Plugin availability and rollback notice persistence have separate limits; see `mem:mcp/save-and-rollback` and `mem:frontend/plugin-save-events`.