You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
diagram: Snapshotter modelErrors appends use non-functional setState (clobber-prone, currently dead code) #728
In src/diagram/Editor.tsx, the snapshot-image onload/onerror handlers append to modelErrors using a non-functional read of state instead of the functional updater form:
(around lines 2216 / 2227 in the function-component conversion; this was this.state.modelErrors in the old class at the pre-conversion HEAD, lines 2056 / 2067). The conversion kept these two appends byte-for-byte faithful to the pre-conversion class behavior.
This read-then-write pattern is clobber-prone under concurrent appends: a concurrent controller onError append in flight could be lost, because the snapshot handler captures a stale modelErrors snapshot rather than reading the latest committed state inside the updater.
Why it matters
Correctness (latent): concurrent appends to modelErrors from the snapshot path and the controller onError path can race and drop an error entry.
Consistency: the other append sites in the same file (onError, appendModelError, handleCloseSnackbar) already use the concurrent-safe functional updater form. These two are the outliers.
Currently dead code
This is not a current bug: the Snapshotter UI is commented out in the Editor render ({/*<Snapshotter .../>*/}), so the snapshot onload/onerror path is unreachable today. Tracking it so it isn't silently re-enabled in a broken state.
When/if the Snapshotter snapshot UI is re-enabled, convert these two appends to the functional updater form to match the other concurrent-safe append sites:
Flagged by the adversarial reviewer during the Editor.tsx class-to-function-component conversion (branch functional-components-migration). Non-blocking tech debt deferred from that review.
Activity