Repository navigation
fix(catalog): send a sync's removals and rewrites in filters of 100 ids, not 500 - #1633
Merged
Merged
Conversation
…ds, not 500 markRemoved and replaceIn put up to 500 ids in one .in() filter, which PostgREST carries in the URL: about 19 kB, past the size chunked-in.js found refused before it reaches PostgREST. A sync that removed or changed more than about 100 products at once could fail there. They now split their ids with chunkIds (100 a request); writes, whose rows go in the body, keep 500. Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 of 12 tasks
4 of 12 tasks
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups.
Merge state. Clean on main, and with #1632. On the tree with both, the catalog and shopping-path tests pass (161).
Checked
markRemovedandreplaceInnow send 100 ids a filter (chunkIds, about 4 kB of URL). Upserts and inserts keep 500 rows a request, which is right: those rows go in the body.chunkIdsalso drops duplicate ids. Both callers pass ids that are already unique, so nothing changes there.- The other
.in()filters on the catalog path already go through 100-id chunks (shopping-path.jsreadIn). - The new test fails when
markRemovedgoes back tochunks().
Follow-ups
- The test doesn't cover the rewrite half. The second sync is an empty feed, so no product is touched and
replaceInnever runs. PuttingreplaceInback onchunks()leaves every test green. A second step that changes the 250 products (a new title or product type) and checks the filter sizes on thecatalog_imagesandcatalog_product_categoriesdeletes would cover it, as the test's title says.
Before the API deploy. Nothing changes. This is in the API's sync only.
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
A catalog sync that removes or changes many products no longer risks a request too long to reach the database.
markRemovedandreplaceIninserver/src/lib/catalog/sync.jsput up to 500 ids in one.in()filter. PostgREST carries that filter in the URL: about 19 kB.chunked-in.jsrecords that requests near 16 kB were often refused at the edge before they reached PostgREST. A sync that removed more than about 100 products at once, or rewrote their images and categories, could fail there and leave the catalog half written.chunkIdsfromchunked-in.js: 100 per request, about 4 kB of URL.Found while writing #1632 (it deletes in 100s for the same reason).
Related issue
None. Follow-up from #1632.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/catalog/sync.test.jsThe new test syncs 250 products and then an empty feed. It checks that all 250 are marked removed with no
.in()filter over 100 ids. With the previouschunks()it fails, since one filter carries 250 ids.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — no web changeyarn typecheckpasses (run fromweb/) — no web changeyarn format:checkpasses (run fromweb/) — no web changeAlso run in
server/:npm run format,npm run lintandnpm test(3,339 tests).🤖 Generated with Claude Code