From 7e7f91f6de202b8751885ef6e84b192e8d25d5d8 Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Thu, 25 Jan 2024 17:30:50 -0500 Subject: [PATCH] Restore cleanup behavior on failed startup (#3119) --- packages/core/src/anchor/ethereum/ethereum-anchor-service.ts | 4 ++-- packages/core/src/ceramic.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/anchor/ethereum/ethereum-anchor-service.ts b/packages/core/src/anchor/ethereum/ethereum-anchor-service.ts index 0a8da5d276..2e38163677 100644 --- a/packages/core/src/anchor/ethereum/ethereum-anchor-service.ts +++ b/packages/core/src/anchor/ethereum/ethereum-anchor-service.ts @@ -133,8 +133,8 @@ export class EthereumAnchorService implements AnchorService { async close(): Promise { this.#logger.debug(`Closing EthereumAnchorService`) - await this.#cas.close() - await this.#store.close() + await this.#cas?.close() + await this.#store?.close() await this.#loop?.stop() } } diff --git a/packages/core/src/ceramic.ts b/packages/core/src/ceramic.ts index 6c0585c3d6..16bea35916 100644 --- a/packages/core/src/ceramic.ts +++ b/packages/core/src/ceramic.ts @@ -486,6 +486,7 @@ export class Ceramic implements StreamReaderWriter, StreamStateLoader { await this._startupChecks() } catch (err) { this._logger.err(err) + await this.close() throw err } }