fix(extension-chrome): skip GitHub round-trip for unmapped update/remove events#15
Merged
Merged
Conversation
…ove events Previously when chrome.bookmarks.onChanged or onRemoved fired for a node with no ULID mapping, the event survived the suppression filter and reached client.update(). The mutate fn correctly no-op'd inside applyBatch (no matching ULID → continue), but the empty mutation still went through a read + put round-trip to GitHub. Filter unmapped update/remove events out of the surviving batch upfront. Creates always survive (the create itself establishes the mapping). The existing 'onChanged for an unmapped node' test was updated to assert client.update was NOT called — previously it documented the bug by acknowledging update was called with a no-op mutate. Closes #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
chrome.bookmarks.onChangedoronRemovedfired for a node with no ULID mapping, the event still reachedclient.update()with a no-op mutate — a wasted GitHub round-trip on every such event.Extend
flushPending'ssurvivingfilter to drop update/remove events for unmapped nodes upfront. Creates still survive (the create itself establishes the mapping).TDD log
expect(update).not.toHaveBeenCalled(). Watched it fail —updateIS called by the current code, matching the bug exactly.idMap.ulidForNode(asNodeId(p.nodeId)) == nullchecks to the update/remove branches of the surviving filter. Test passes; full suite 69/69.Test plan
pnpm test69/69 (no count change — existing test became the regression guard)pnpm typecheckcleanCloses #8