From 5f8a15b2a5c1593af0fd2847625f393fc80b7bd5 Mon Sep 17 00:00:00 2001 From: Isla Koenigsknecht Date: Tue, 10 Dec 2024 13:39:36 -0500 Subject: [PATCH] Fix backend tests --- packages/backend/src/nest/ipfs/ipfs.service.ts | 10 +++++++++- packages/backend/src/nest/libp2p/libp2p.service.ts | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/nest/ipfs/ipfs.service.ts b/packages/backend/src/nest/ipfs/ipfs.service.ts index 49f77f0454..3dfade7410 100644 --- a/packages/backend/src/nest/ipfs/ipfs.service.ts +++ b/packages/backend/src/nest/ipfs/ipfs.service.ts @@ -151,7 +151,15 @@ export class IpfsService { await this.blockstore?.db.close() await this.blockstore?.close() await this.datastore?.close() - await this.ipfsInstance.stop() + + try { + await this.ipfsInstance?.stop() + } catch (e) { + if ((e as Error).message !== 'Database is not open') { + this.logger.error(`Error while closing IPFS instance`, e) + throw e + } + } this.started = false } diff --git a/packages/backend/src/nest/libp2p/libp2p.service.ts b/packages/backend/src/nest/libp2p/libp2p.service.ts index 720a429665..986f9d8bc8 100644 --- a/packages/backend/src/nest/libp2p/libp2p.service.ts +++ b/packages/backend/src/nest/libp2p/libp2p.service.ts @@ -387,7 +387,7 @@ export class Libp2pService extends EventEmitter { clearTimeout(this.redialTimeout) await this.hangUpPeers() await this.libp2pInstance?.stop() - await this.libp2pDatastore.close() + await this.libp2pDatastore?.close() this.libp2pInstance = null this.connectedPeers = new Map()