Unbounded Promise.all Calls Can Overwhelm APIs and Databases, Developer Warns
A scheduled billing job that ran Promise.all across 1,200 customer records triggered rate-limit errors from a payment gateway and connection pool timeouts in PostgreSQL within 400 milliseconds. The author explains that Promise.all does not throttle execution, because map() invokes every async callback at once, which can flood external APIs and exhaust database connection pools. Failures also leave orphaned side effects, since a rejected Promise.all does not cancel the remaining in-flight operations. In a simulated benchmark, an unbounded approach crashed with zero completed tasks while a bounded worker pool finished all 200 tasks in about 1,045 milliseconds. The article recommends a concurrency-limited worker pool with an AbortController as a safer alternative.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in