From 924e202662e06ddc30bb6cad23d66c00aa1190be Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Thu, 8 Jun 2023 23:35:35 +0800 Subject: [PATCH] fix: start wiki twice in unknown reason --- src/services/wiki/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/wiki/index.ts b/src/services/wiki/index.ts index 389b7ffdd..671e0f1bb 100644 --- a/src/services/wiki/index.ts +++ b/src/services/wiki/index.ts @@ -98,8 +98,10 @@ export class Wiki implements IWikiService { logger.error('Try to start wiki, but workspace ID not provided', { workspaceID }); return; } - if (this.getWorker(workspaceID) !== undefined) { - throw new DoubleWikiInstanceError(workspaceID); + const previousWorker = this.getWorker(workspaceID); + if (previousWorker !== undefined) { + logger.error(new DoubleWikiInstanceError(workspaceID)); + await this.stopWiki(workspaceID); } // use Promise to handle worker callbacks const workspace = await this.workspaceService.get(workspaceID); @@ -246,7 +248,6 @@ export class Wiki implements IWikiService { logger.warning(`No wiki for ${id}. No running worker, means maybe tiddlywiki server in this workspace failed to start`, { function: 'stopWiki', }); - await Promise.resolve(); return; } clearInterval(this.wikiSyncIntervals[id]);