Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: TypeScript
performanceconcurrencyasyncrate-limiting
Throttle large batches of concurrent promises with a pool
When fanning out many async operations, cap concurrency with a promise pool instead of an unbounded Promise.all that can overwhelm the downstream system.
PR: hegnar-shareholders-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | await Promise.all(thousandsOfIds.map((id) => fetchAndStore(id))); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const POOL_SIZE = 20; |
| 2 | await promiseAllPool( |
| 3 | thousandsOfIds.map((id) => () => fetchAndStore(id)), |
| 4 | POOL_SIZE, |
| 5 | ); |
Explanation (EN)
Objašnjenje (HR)