From 0f23f16ce5f2620b36350e7bdddf7e48d8273af4 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Wed, 16 Mar 2022 19:36:09 -0700 Subject: [PATCH] Core data: Fall back to default API batch size of 25. 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. --- packages/core-data/src/batch/default-processor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core-data/src/batch/default-processor.js b/packages/core-data/src/batch/default-processor.js index 34f38ff5c3d0da..477f67e78106e1 100644 --- a/packages/core-data/src/batch/default-processor.js +++ b/packages/core-data/src/batch/default-processor.js @@ -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; @@ -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',