https://sonarly.com/issue/19549?type=bug
A `FindOneCompany` GraphQL query fails with "Connection terminated unexpectedly" when the server fires many parallel relation queries that exhaust or destabilize the PostgreSQL connection pool under memory pressure.
Fix: Replaced `Promise.all` with a sequential `for...of` loop in `ProcessNestedRelationsV2Helper.processNestedRelations()` to serialize nested relation database queries.
**Problem:** The `FindOneCompany` GraphQL query (and similar record queries) request 10+ relations simultaneously (accountOwner, attachments, favorites, people, noteTargets, opportunities, timelineActivities, etc.). The previous code fired all these as parallel database queries via `Promise.all`, which could exhaust the default PostgreSQL connection pool (10 connections), causing `Connection terminated unexpectedly` errors.
**Fix:** Sequential execution ensures only 1 relation query runs at a time, keeping concurrent DB connections well within pool limits. Individual relation queries are fast (typically 2-50ms), so serialization adds negligible wall-clock time (~100-500ms total for 10 relations) compared to the catastrophic failure it prevents.
**Precedent:** This follows the exact same pattern merged in commit `0a1ac48eea` which serialized cache recomputation in `WorkspaceCacheService.recomputeDataFromProvider()` to prevent the same class of pool exhaustion bug.