Repository navigation
fix(javascript): chunked push polling offset and batchSize forwarding - #6598
Merged
Merged
Conversation
Contributor
💥 Breaking changes detected !!Either this PR or a previous PR not released yet introduced breaking changes, be careful when merging. ✔️ Code generated!
📊 Benchmark resultsBenchmarks performed on the method using a mock server, the results might not reflect the real-world performance.
|
Fluf22
reviewed
Jun 23, 2026
Fluf22
left a comment
Collaborator
There was a problem hiding this comment.
Only one comment: can you please gate against weird batchSize values (zero or negative)?
eric-zaharia
marked this pull request as draft
June 24, 2026 06:41
eric-zaharia
marked this pull request as ready for review
June 24, 2026 07:10
Fluf22
approved these changes
Jun 24, 2026
algolia-api-clients-automation-bot Bot
added a commit
that referenced
this pull request
Jun 24, 2026
…#6598) (generated) [skip ci] Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-api-clients-automation-bot Bot
added a commit
to algolia/algoliasearch-client-javascript
that referenced
this pull request
Jun 24, 2026
… (generated) algolia/api-clients-automation#6598 Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com> Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
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.
🧭 What and Why
🎟 JIRA Ticket: API-503
Fixes two independent defects in the JavaScript transformation/push helpers that together caused
waitForTasksto silently under-poll pushed tasks.Offset over-advance in
chunkedPush. The poll cursor was advanced on every object iteration rather than only when a new batch was pushed. Onceresponses.lengthreached a multiple ofwaitBatchSize, theresponses.length % waitBatchSize === 0gate stayed true on subsequent non-push iterations, slicing empty ranges and runningoffsetpast the real responses — so most pushed tasks were never polled. Slicing an empty range is a no-op, so there was no crash, hence "silent". Only manifests with multiple wait windows (large inputs).batchSizedropped by two wrappers.saveObjectsWithTransformationandpartialUpdateObjectsWithTransformationdestructured their options withoutbatchSize, so it never reachedchunkedPushand chunking never happened through those entry points (replaceAllObjectsWithTransformationalready forwarded it). A single push left nothing for the cursor to overrun, which masked defect 1 in the existing CTS proof.The fix mirrors the Python reference (#6486): gated wait + bounded cursor + post-loop drain.
Changes included:
chunkedPush(templates/javascript/clients/client/api/ingestionHelpers.mustache): extract the polling loop into awaitForBatch(start, end)closure; replace the% waitBatchSizegate withresponses.length - offset >= waitBatchSize, advance the cursor by exactlywaitBatchSize, and drain the remaining tail after the loop.templates/javascript/clients/algoliasearch/builds/definition.mustache): forwardbatchSizetochunkedPushinsaveObjectsWithTransformationandpartialUpdateObjectsWithTransformation.chunkedPushWaitCTS proof forjavascript(tests/CTS/client/search/saveObjectsWithTransformation.jsonand the assertion count inscripts/cts/runCts.ts).🧪 Test
Covered by the existing
chunkedPushWaitCTS scenario —saveObjectsWithTransformationwith 25 objects,waitForTasks: true,batchSize: 10→ 3 pushes. The test server assertsgetEventCount === pushCountand that the set of distinct polledeventIDs equalspushCount, i.e. every pushed task is polled exactly once. Before this PR the scenario was skipped for JS; it now runs. PHP remains skipped for this scenario.