Skip to content

Commit c51a576

Browse files
authored
Fix Startup Order (#1290)
Closes #1289
1 parent 95afe88 commit c51a576

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/dbos.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,13 @@ export class DBOS {
464464
recordDBOSLaunch();
465465

466466
const executor: DBOSExecutor = DBOSExecutor.globalInstance;
467+
468+
// Initialize data sources before executor.init() dispatches recovery, so recovered
469+
// workflows can run their transactions immediately instead of racing initialization.
470+
for (const [_n, ds] of transactionalDataSources) {
471+
await ds.initialize();
472+
}
473+
467474
await executor.init();
468475

469476
// Register the current application version
@@ -476,9 +483,6 @@ export class DBOS {
476483
}
477484

478485
await DBOSExecutor.globalInstance.initEventReceivers(this.#dbosConfig?.listenQueues || null);
479-
for (const [_n, ds] of transactionalDataSources) {
480-
await ds.initialize();
481-
}
482486

483487
if (globalParams.dbosCloud) {
484488
const cloudAppName = process.env.DBOS__CONDUCTOR_APP_NAME;

0 commit comments

Comments
 (0)