From d400c15161b53cf20ea1e2a76e5025a85a28fa3a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:50:07 +0000 Subject: [PATCH] Fix: Delay log folder creation until primary instance is confirmed Move log folder (logsHome) creation from initServices() to after claimInstance() succeeds. This prevents secondary instances from creating empty log folders when they simply connect to the primary instance and exit. Fixes #250334 Co-authored-by: sandy081 <10746682+sandy081@users.noreply.github.com> --- src/vs/code/electron-main/main.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 8ea3d44a286..c152ad50601 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -134,6 +134,10 @@ class CodeMain { logService.warn(`app#startup(): Error writing main lockfile: ${err.stack}`); }); + // Create logs folder now that we are the primary instance + // (https://github.com/microsoft/vscode/issues/250334) + await promises.mkdir(environmentMainService.logsHome.with({ scheme: Schemas.file }).fsPath, { recursive: true }); + // Delay creation of spdlog for perf reasons (https://github.com/microsoft/vscode/issues/72906) bufferLogger.logger = loggerService.createLogger('main', { name: localize('mainLog', "Main") }); @@ -268,10 +272,11 @@ class CodeMain { await Promises.settled([ // Environment service (paths) + // Note: logsHome is not created here to avoid creating empty log folders + // for secondary instances. It is created later after claimInstance succeeds. Promise.all([ this.allowWindowsUNCPath(environmentMainService.extensionsPath), // enable extension paths on UNC drives... environmentMainService.codeCachePath, // ...other user-data-derived paths should already be enlisted from `main.js` - environmentMainService.logsHome.with({ scheme: Schemas.file }).fsPath, userDataProfilesMainService.defaultProfile.globalStorageHome.with({ scheme: Schemas.file }).fsPath, environmentMainService.workspaceStorageHome.with({ scheme: Schemas.file }).fsPath, environmentMainService.localHistoryHome.with({ scheme: Schemas.file }).fsPath,