From 860dc8bfde017c4cfa8d4e143e1d52220adaf9da Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sat, 4 Apr 2026 05:16:08 +0800 Subject: [PATCH] fix: e2e failed --- features/stepDefinitions/wiki.ts | 9 ++++++--- src/services/wikiGitWorkspace/index.ts | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/features/stepDefinitions/wiki.ts b/features/stepDefinitions/wiki.ts index 74903474..0741c3a4 100644 --- a/features/stepDefinitions/wiki.ts +++ b/features/stepDefinitions/wiki.ts @@ -1187,9 +1187,12 @@ When('I update workspace {string} settings:', async function(this: ApplicationWo // wiki worker initialization can take several seconds. await waitForLogMarker(this, '[test-id-WIKI_WORKER_STARTED]', 'wiki worker not started before restart attempt'); - // Only wait for watch-fs if it was enabled before the update - // If it was disabled, wiki is ready immediately without watch-fs markers - if (watchFsCurrentlyEnabled) { + // Wait for watch-fs to stabilize before restarting to avoid nsfw crash. + // If watch-fs was already enabled OR is being enabled in this update, the wiki worker + // may have started nsfw already (it reads updated settings on start). We must wait for + // it to fully initialize before calling terminateWorker, otherwise the native nsfw + // polling thread may try to callback into a destroyed JS environment (FATAL napi error). + if (watchFsCurrentlyEnabled || settingsUpdate.enableFileSystemWatch === true) { await waitForLogMarker(this, '[test-id-WATCH_FS_STABILIZED]', 'watch-fs not ready before restart', LOG_MARKER_WAIT_TIMEOUT); } diff --git a/src/services/wikiGitWorkspace/index.ts b/src/services/wikiGitWorkspace/index.ts index e977592d..f6161c50 100644 --- a/src/services/wikiGitWorkspace/index.ts +++ b/src/services/wikiGitWorkspace/index.ts @@ -82,6 +82,8 @@ export class WikiGitWorkspace implements IWikiGitWorkspaceService { const isSyncedWiki = storageService !== SupportedStorageServices.local; if (await hasGit(wikiFolderLocation)) { logger.warn('Skip git init because it already has a git setup.', { wikiFolderLocation }); + // Still emit the marker so e2e tests waiting for git-init-complete don't hang + logger.info(`[test-id-git-init-complete]`, { wikiFolderLocation }); } else { if (isSyncedWiki) { if (typeof gitUrl === 'string' && userInfo !== undefined) {