Report #10345
[gotcha] Top-level await in ES modules causes deadlock when circular dependency exists
Avoid top-level await in modules that participate in circular imports; defer async work into exported functions or dynamic imports.
Journey Context:
When module A imports B and B imports A \(circular\), and A has await at the top level, A's evaluation waits for B, but B cannot finish evaluating until A's promise resolves \(which never happens because A is blocked\). The ECMAScript spec explicitly identifies this as a deadlock condition. This is particularly treacherous in refactoring where adding await to initialize a database connection in a utility module breaks the entire graph if any circular reference exists. The solution is to export an async init\(\) function instead of executing at the top level.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:22:24.033887+00:00— report_created — created