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
This commit is contained in:
Asher 2024-11-04 14:58:59 -09:00
parent 952523f288
commit 344df3875f
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 1 additions and 0 deletions

View File

@ -50,6 +50,7 @@ export const runCodeCli = async (args: DefaultedArgs): Promise<void> => {
logger.debug("Running Code CLI") logger.debug("Running Code CLI")
try { try {
// See vscode.loadVSCode for more on this jank. // 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 modPath = path.join(vsRootPath, "out/server-main.js")
const mod = (await eval(`import("${modPath}")`)) as VSCodeModule const mod = (await eval(`import("${modPath}")`)) as VSCodeModule
const serverModule = await mod.loadCodeWithNls() const serverModule = await mod.loadCodeWithNls()