Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Run independent async calls concurrently with Promise.all instead of awaiting them one after another
When two or more async operations don't depend on each other's results, issue them concurrently with Promise.all rather than awaiting them sequentially — sequential awaits needlessly add their latencies together instead of overlapping them.
Bad example
| 1 | const profile = await loadPublicProfile(id); |
| 2 | const themes = await loadPublicThemes(); |
Explanation (EN)
Two genuinely independent reads pay unnecessary combined waiting time when started sequentially.
Objašnjenje (HR)
Dva neovisna čitanja nepotrebno zbrajaju vrijeme čekanja ako se pokreću uzastopno.
Good example
| 1 | const [profile, themes] = await Promise.all([ |
| 2 | loadPublicProfile(id), |
| 3 | loadPublicThemes(), |
| 4 | ]); |
Explanation (EN)
Both independent public reads begin together; neither is authorized or gated by the other result.
Objašnjenje (HR)
Oba neovisna javna čitanja započinju zajedno; ni autorizacija ni dopuštenje jednog ne ovise o rezultatu drugog.
Notes (EN)
Run calls concurrently only when they are independent in authorization, existence checks, side effects, resource limits and failure policy, not merely in argument data.
Exceptions / Tradeoffs (EN)
Keep sequencing when one check gates the other operation. Promise.all rejects early without cancelling siblings; bound large fan-out and decide whether every result is required.