Skip to content

Commit 7831fa4

Browse files
committed
fix: wait some time and restart the wiki will solve "Did not receive an init message from worker after"
fixes andywer/threads.js#426
1 parent cd2b790 commit 7831fa4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/services/wiki/index.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,15 @@ export class Wiki implements IWikiService {
553553
// don't want it to throw here again, so no await here.
554554
// eslint-disable-next-line @typescript-eslint/return-await
555555
return this.workspaceViewService.restartWorkspaceViewService(id);
556+
} else if ((error as Error).message.includes('Did not receive an init message from worker after')) {
557+
// https://github.com/andywer/threads.js/issues/426
558+
// wait some time and restart the wiki will solve this
559+
logger.warn(`Get startWiki() handle "${(error as Error)?.message}", will try restart wiki.`);
560+
await this.restartWiki(workspace);
561+
} else {
562+
logger.warn('Get startWiki() unexpected error, throw it');
563+
throw error;
556564
}
557-
logger.warn('Get startWiki() unexpected error, throw it');
558-
throw error;
559565
}
560566
} else {
561567
// if is private repo wiki
@@ -572,7 +578,7 @@ export class Wiki implements IWikiService {
572578
}
573579

574580
public async restartWiki(workspace: IWorkspace): Promise<void> {
575-
const { wikiFolderLocation, port, userName: workspaceUserName, isSubWiki, syncOnInterval } = workspace;
581+
const { wikiFolderLocation, port, userName: workspaceUserName, isSubWiki } = workspace;
576582
// use workspace specific userName first, and fall back to preferences' userName, pass empty editor username if undefined
577583
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
578584
const userName = (workspaceUserName || (await this.authService.get('userName'))) ?? '';

0 commit comments

Comments
 (0)