From 344df3875fee5979b5fda0c6bf00778d0ef1be48 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 4 Nov 2024 14:58:59 -0900 Subject: [PATCH] Fix cli being ran twice server-main.js runs itself outside a code-server context, which is determined using the CODE_SERVER_PARENT_PID environment variable. This is set by the wrapper, but there is no wrapper when running the cli (only for the server), so this resulting in the cli running twice (one self-run on initial import, again when we run spawnCli). This might fix https://github.com/coder/code-server/issues/7042 --- src/node/main.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node/main.ts b/src/node/main.ts index f331ae59f..b3c4e4c14 100644 --- a/src/node/main.ts +++ b/src/node/main.ts @@ -50,6 +50,7 @@ export const runCodeCli = async (args: DefaultedArgs): Promise => { logger.debug("Running Code CLI") try { // See vscode.loadVSCode for more on this jank. + process.env.CODE_SERVER_PARENT_PID = process.pid.toString() const modPath = path.join(vsRootPath, "out/server-main.js") const mod = (await eval(`import("${modPath}")`)) as VSCodeModule const serverModule = await mod.loadCodeWithNls()