Skip to content

Fix flow-view mount race (StrictMode double-fetch)#24

Merged
damusix merged 2 commits into
mainfrom
fix-flow-search-race
Jul 15, 2026
Merged

Fix flow-view mount race (StrictMode double-fetch)#24
damusix merged 2 commits into
mainfrom
fix-flow-search-race

Conversation

@damusix

@damusix damusix commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • useModelData's boot fetch had no cancellation, so React StrictMode's dev-mode double-invoke fired it twice; the stale first response landed after its own effect cleaned up and reset flowDiagrams/model with a fresh reference, retriggering the flow renderer's mount effect while the prior mount was still settling — two live React roots ended up writing into the same shared container.
  • Fixed with the standard React ignore-flag cleanup pattern on the fetch effect, plus a disposed guard on FlowsView's async renderDiagram so any orphaned continuation from a torn-down instance bails instead of racing for the container.

What this solves

Console errors on flow-view mount in dev (ignatius serve / bun run dev): "Cannot update an unmounted root" / "Attempted to synchronously unmount a root while React was already rendering." Reproduced live, fixed, and confirmed clean across repeated fresh loads.

damusix added 2 commits July 14, 2026 23:55
useModelData's boot fetch had no cancellation, so React StrictMode's
dev-mode mount->cleanup->mount double-invoke fired it twice; the first
response still landed after its own effect cleaned up and reset
flowDiagrams/model with a fresh reference, retriggering FlowsView's
render effect while the prior mount was still settling. Two live React
roots ended up writing into the same shared container, surfacing as
"Cannot update an unmounted root" / "Attempted to synchronously unmount
a root while React was already rendering" on flow-view mount.

Guards the fetch effect with the standard ignore-flag cleanup pattern,
and separately hardens FlowsView's renderDiagram against any instance
whose owning effect was torn down while it awaited ELK layout.
@damusix
damusix marked this pull request as ready for review July 15, 2026 05:13
@damusix
damusix merged commit e91248d into main Jul 15, 2026
0 of 2 checks passed
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