refactor: split large pushData calls into chunks fitting the platform payload limit - #682
Open
B4nan wants to merge 4 commits into
Open
refactor: split large pushData calls into chunks fitting the platform payload limit#682B4nan wants to merge 4 commits into
B4nan wants to merge 4 commits into
Conversation
…oad limit The Apify API rejects dataset push requests over 9MB. SDK v3 split oversized pushes into chunks under the limit (via crawlee v3's Dataset), but crawlee v4 removed that logic expecting storage backends to handle it, so pushing a large batch failed with an API error. Restore the v3 behavior in ApifyDatasetBackend.pushData: items are serialized, split into chunks fitting the limit, and pushed sequentially, preserving order. A single item exceeding the limit throws a descriptive error. Closes #603
The crawlee beta.105 bump stopped re-exporting Dictionary from crawlee and @crawlee/utils (import it from @crawlee/types instead), and the getRequest mock arity no longer matched the mocked signature. These errors are only visible to tsc-check-tests, which CI does not run.
The tsc-check-tests script existed but no CI job ran it, so type errors in test files went unnoticed (e.g. the crawlee beta.105 bump broke three test imports without failing any check). Run it in the lint job — the test tsconfig resolves the apify package from src/, so no build is needed.
Tighten the per-item size limit by the 2-byte array wrapper so a lone maximal item cannot exceed the chunk size contract, and pin the chunking behavior with boundary tests (at-limit, one byte over, multi-byte UTF-8, empty push). Update stale PatchedDatasetClient comment references to PpeAwareDatasetClient.
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.
Actor.pushData()/Dataset.pushData()failed with an API error when the payload exceeded the platform's 9MB per-request limit. SDK v3 split such pushes into chunks under the limit (in crawlee v3'sDataset). Crawlee v4 removed that logic (apify/crawlee#3627), expecting storage backends to handle it, andapify-clientsends one unchunked POST, so v4 regressed against v3.This restores the v3 behavior in
ApifyDatasetBackend.pushData: it serializes the items, groups them into chunks that fit the limit (keeping v3's small safety buffer), and pushes the chunks sequentially to preserve item order. A single item over the limit throws a descriptive error, same as in v3. The pay-per-event interception path already aggregates charge results across multiplepushItems()calls per push, and now has test coverage for chunked pushes.Closes #603
Also fixes three test-only type errors from the crawlee beta.105 bump (
Dictionaryis no longer re-exported fromcrawlee/@crawlee/utils, and a mock arity no longer matched). These only surface inpnpm tsc-check-tests, which CI does not run.