Skip to content

refactor: split large pushData calls into chunks fitting the platform payload limit - #682

Open
B4nan wants to merge 4 commits into
v4from
fix/dataset-push-9mb-chunking
Open

refactor: split large pushData calls into chunks fitting the platform payload limit#682
B4nan wants to merge 4 commits into
v4from
fix/dataset-push-9mb-chunking

Conversation

@B4nan

@B4nan B4nan commented Aug 7, 2026

Copy link
Copy Markdown
Member

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's Dataset). Crawlee v4 removed that logic (apify/crawlee#3627), expecting storage backends to handle it, and apify-client sends 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 multiple pushItems() 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 (Dictionary is no longer re-exported from crawlee / @crawlee/utils, and a mock arity no longer matched). These only surface in pnpm tsc-check-tests, which CI does not run.

…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
@B4nan B4nan added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels Aug 7, 2026
B4nan added 2 commits August 7, 2026 13:20
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.
@B4nan B4nan changed the title fix: split large pushData calls into chunks fitting the platform payload limit feat: split large pushData calls into chunks fitting the platform payload limit Aug 7, 2026
@B4nan B4nan changed the title feat: split large pushData calls into chunks fitting the platform payload limit refactor: split large pushData calls into chunks fitting the platform payload limit Aug 7, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants