Skip to content
This repository was archived by the owner on Nov 6, 2026. It is now read-only.

fix(dom): a reconcile that throws clears the element's state instead of freezing it (#82) - #84

Closed
markaddleman wants to merge 1 commit into
cjohansen:mainfrom
pyze:fix/render-throw-clears-state
Closed

markaddleman wants to merge 1 commit into
cjohansen:mainfrom
pyze:fix/render-throw-clears-state

Conversation

@markaddleman

Copy link
Copy Markdown

Closes #82.

Problem

When reconcile throws inside replicant.dom/render, clearing the latch alone is not enough because the patch stopped part way and the DOM matches no vdom. Keeping :current makes the next render diff the live DOM against a tree that does not describe it, which is the same disagreement that threw. Furthermore, swallowing the error into console.error masks the failure from the caller.

Fix

In replicant.dom/render:

  • Drop the entire element entry from state on throw via (vswap! state dissoc el). The next render finds no entry, clears innerHTML, and mounts cleanly from nil.
  • Re-throw the error so render failures are visible to the caller rather than silently swallowed.

Verification

Ran test suites against main:

  • Clojure (JVM Kaocha): clojure -X:dev:test -> 24 tests, 300 assertions, 0 failures.
  • ClojureScript (Node.js runner): clojure -M:test-cljs -> 19 tests, 259 assertions, 0 failures, 0 errors.

…of freezing it

When reconcile throws, clearing the latch alone is not enough because the
patch stopped part way and the live DOM matches no vdom. Keeping :current
makes the next render diff the live DOM against a tree that does not
describe it, which is the same disagreement that threw.

Dropping the whole entry from state allows the next render to find no entry,
clearing innerHTML and painting from nil cleanly. Re-throwing the error
ensures render failures are not silently masked so callers can react.

Closes cjohansen#82.
@cjohansen

Copy link
Copy Markdown
Owner

I solved this in a similar fashion myself. As stated in the Readme, I don't take LLM contibutions. This PR has many LLM-isms, and your previous PR had Claude explicitly mentioned. The commits are also using a "conventional commit" template that is alien to this codebase, and that I have in fact actively decided not to use.

@cjohansen cjohansen closed this Nov 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A reconcile that throws leaves :rendering? set, so the element never paints again

2 participants