Skip to content

fix(extension-chrome): chain update/remove through createUlids within one batch#22

Merged
paperhurts merged 1 commit into
mainfrom
fix/create-update-race
May 24, 2026
Merged

fix(extension-chrome): chain update/remove through createUlids within one batch#22
paperhurts merged 1 commit into
mainfrom
fix/create-update-race

Conversation

@paperhurts
Copy link
Copy Markdown
Owner

Pre-existing race the second PR review surfaced (filed as #19). When create + rename land in the same 500ms debounce window the update was silently dropped.

Fix

Pre-compute a Set of nodeIds with create events in the current batch. The surviving filter accepts update/remove events for nodes either already in idMap OR being created in this batch. applyBatch consults createUlids when idMap returns null.

TDD

  • RED: create + update on the same nodeId within one batch lands with the updated title (issue #19) — captured the produced file, asserted title was 'Renamed'; watched it fail (file had 'Original').
  • GREEN: filter + applyBatch changes; test passes; full suite 94/94.

Closes #19

… one batch

When a user creates a bookmark and immediately renames it within the
500ms debounce window, both events land in the same flush batch.
Previously:
- The surviving filter saw idMap.ulidForNode(updateEvent.nodeId) == null
  (the id-map mutation is deferred until after the write succeeds) and
  dropped the update.
- Even if the update had survived the filter, applyBatch's update branch
  would have continue'd for the same reason.
- Result: the first GitHub commit had the ORIGINAL title; the rename
  was silently dropped until the user triggered another event.

Pre-compute a set of nodeIds with create events in the same batch.
The surviving filter accepts update/remove events for nodes either
already mapped OR being created in this batch. applyBatch's update
and remove branches consult createUlids when idMap returns null.

TDD: failing test asserted final BookmarksFile carries 'Renamed' title;
watched it fail RED (file had 'Original'). Implementation lifts;
all 94 tests green (was 93).

Closes #19
@paperhurts paperhurts merged commit 9a3b1e6 into main May 24, 2026
1 check passed
@paperhurts paperhurts deleted the fix/create-update-race branch May 24, 2026 04:07
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.

Pre-existing: create+update on same nodeId within debounce drops the update

1 participant