After recently dealing with Storage limits when handling large JSON responses from web requests, I’ve encountered another related issue.
When sending a request using Communications.makeWebRequest
, the app continues to process other events until the response is received. In my case, these requests are used to update already displayed data, and the user can interact with the app while updates are processed. To avoid blocking the UI, I handle the response inside a task queue, which chunks the processing of the large JSON—this part works well on my end.
However, I’ve observed a problem with the processing that occurs before my callback is triggered. In most cases, even with large (but within-limit) JSON responses, the pre-callback processing is fast enough not to affect the user experience. But occasionally, the delay before the callback is invoked spikes to 4–5 seconds, during which the UI becomes unresponsive.
Here’s a log excerpt from one instance where this occurs:
28.5.2025 15:01:14: TaskQueue: start executing tasks (12 queued)
28.5.2025 15:01:14: SitemapRequest.makeRequest (#5)
28.5.2025 15:01:14: TaskQueue: stop executing tasks after 46ms (0 remaining)
28.5.2025 15:01:18: SitemapRequest.onReceive: start (#5)
28.5.2025 15:01:18: SitemapRequest.onReceive: end
There is a 4-second delay between makeRequest
and the start of onReceive
, which is not typical. The request is sent to a local server, so network latency is not a factor. Also, if the delay were due to a slow response, I would expect the app not to block.
For comparison, here’s a log from a typical case—same server, same JSON response:
29.5.2025 11:25:47: TaskQueue: start executing tasks (3 queued)
29.5.2025 11:25:47: SitemapRequest.makeRequest (#7)
29.5.2025 11:25:47: TaskQueue: stop executing tasks after 62ms (0 remaining)
29.5.2025 11:25:47: SitemapRequest.onReceive: start (#7)
29.5.2025 11:25:47: SitemapRequest.onReceive: end
I’m trying to understand what might be causing the API’s internal processing—between the network response and the invocation of the callback—to occasionally take significantly longer, blocking the app during that time.
Has anyone else experienced similar issues with large JSON responses and delayed callbacks in makeWebRequest
? Any insights or workarounds would be appreciated.