Skip to content

Commit

Permalink
fix: start wiki twice in unknown reason
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Jun 8, 2023
1 parent 037e6f7 commit 924e202
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/services/wiki/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 924e202

Please sign in to comment.