Skip to content

Commit

Permalink
fix(datastore): close localchain on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Oct 30, 2024
1 parent f7b7d43 commit 60d7f33
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions datastore/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,20 +439,21 @@ export default class DatastoreCore extends TypedEventEmitter<{
try {
await this.workTracker?.stop(this.options.waitForDatastoreCompletionOnShutdown);

for (const plugin of Object.values(this.pluginCoresByName)) {
if (plugin.onCoreClose) await plugin.onCoreClose();
}
this.pluginCoresByName = {};

for (const connection of this.connections) {
await connection.disconnect();
}
this.connections.clear();
await this.datastoreRegistry?.close();
await this.storageEngineRegistry?.close();

await this.datastoreApiClients?.close();
await this.statsTracker?.close();
await Promise.allSettled([
...Object.values(this.pluginCoresByName).map(x => x.onCoreClose?.()),
this.datastoreRegistry?.close(),
this.storageEngineRegistry?.close(),
this.localchain?.close(),
this.upstreamDatastorePaymentService?.close(),
this.datastoreApiClients?.close(),
this.statsTracker?.close(),
]);
this.pluginCoresByName = {};

closingPromise.resolve();
} catch (error) {
Expand Down

0 comments on commit 60d7f33

Please sign in to comment.