Skip to content

Commit

Permalink
Core data: Fall back to default API batch size of 25.
Browse files Browse the repository at this point in the history
Part of #39211

Previously it was possible that we fail to register a batch size from
the server and we leave the batch size null.

In this patch we fallback to the Core-defined default of 25.
  • Loading branch information
dmsnell committed Mar 22, 2022
1 parent ce74a0d commit 0f23f16
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/core-data/src/batch/default-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import apiFetch from '@wordpress/api-fetch';
* Maximum number of requests to place in a single batch request. Obtained by
* sending a preflight OPTIONS request to /batch/v1/.
*
* @type {number?}
* @type {number|null}
* @default 25 (set by Core)
*/
let maxItems = null;

Expand All @@ -36,7 +37,7 @@ export default async function defaultProcessor( requests ) {

const results = [];

for ( const batchRequests of chunk( requests, maxItems ) ) {
for ( const batchRequests of chunk( requests, maxItems ?? 25 ) ) {
const batchResponse = await apiFetch( {
path: '/batch/v1',
method: 'POST',
Expand Down

0 comments on commit 0f23f16

Please sign in to comment.