Postman flow - dealing with large arrays - out of memory

I’m working on a flow that needs to process a large array of JSON objects fetched from an API. The response is stored in the body variable of a GET request, containing over 1000 JSON objects. I’m encountering out of memory errors when trying to process this data. Here’s my current approach:

  1. Send a GET request to fetch the data (resulting in one large array with 1000+ JSON objects in the response body).
  2. Select the body of the response for further processing.
  3. Use a For loop to iterate through all elements in the array.
  4. Evaluate each use a TypeScript script to perform checks (e.g., verifying if the body is an array, fetching certain values, etc.).

However, I’m getting out of memory errors in the first Evaluate step.

The API doesn’t currently support pagination, though I plan to request this feature from the provider.

My question is: Is it possible to chunk this large array into smaller pieces within Postman Flows and then process these smaller chunks? I’m looking for a way to handle this data without running into memory issues.

Hi @baddyz

Welcome to the forums!

Sorry to hear about your error.

Could you verify a few things for me:

  1. Are you running this locally by pressing the “run” button on the flow, not via a webhook on Postman’s cloud?
  2. Since the request executes, but the flow fails in the evaluate block inside the for loop, could you try slicing the array before passing it into the for loop to just verify a subset of the data like 10 records works successfully? (in TypeScript: array.slice(0, 10))

Hi @flows-daniel Thanks for your warm welcome.

Regarding your questions and the issue I’m facing:

  1. Yes, I am running it locally.
  2. I tried using array.slice(0, 10) as you suggested, but I’m still encountering an out-of-memory error. Here’s a screenshot of the error:

The array is quite large, containing numerous objects. Unfortunately, I can’t limit its size or use pagination.

Hi @baddyz

Thank you for your response. Unfortunately, we don’t have a workaround for this issue at the moment, as we need to load the array into memory to process it.

I spoke with our backend team, and we will increase the memory available to the evaluate block to help address this issue. However, I don’t have a specific ETA on when this will be completed.

In the meantime, we hope the API will add pagination support.

Thanks for your time Daniel!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.