API reference › @evolu/common › local‑first/Db › WaitForDatabaseRelease

type WaitForDatabaseRelease = (name: Name) => Task<void, DatabaseHeldError>;

Defined in: packages/common/src/local-first/Db.ts:473

Waits until no other context holds the files of the persistent database name, and fails with DatabaseHeldError when they stay held.

startDbWorker calls it, except for a memory-only database, while it holds the database's leader lock and before it opens the database. Only a context that ended without closing the database can then hold its files, and such a context can only release them, so the files stay free until the database opens. On React Native, whose lock manager is per runtime, a runtime that a reload is replacing can still open the files after the wait, so its driver also retries an open that finds them held. Platforms whose databases cannot be held this way, such as Node.js, omit it.