Skip to content

Commit b53bd6e

Browse files
code-asheryiliang114
authored andcommitted
Fix masking exit code
Addresses the part of coder#6367 that we can fix.
1 parent 5efe454 commit b53bd6e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/node/main.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,17 @@ export const runCodeCli = async (args: DefaultedArgs): Promise<void> => {
5252

5353
try {
5454
await spawnCli(await toCodeArgs(args))
55+
// Rather than have the caller handle errors and exit, spawnCli will exit
56+
// itself. Additionally, it does this on a timeout set to 0. So, try
57+
// waiting for VS Code to exit before giving up and doing it ourselves.
58+
await new Promise((r) => setTimeout(r, 1000))
59+
logger.warn("Code never exited")
60+
process.exit(0)
5561
} catch (error: any) {
62+
// spawnCli catches all errors, but just in case that changes.
5663
logger.error("Got error from Code", error)
5764
process.exit(1)
5865
}
59-
60-
process.exit(0)
6166
}
6267

6368
export const openInExistingInstance = async (args: DefaultedArgs, socketPath: string): Promise<void> => {

0 commit comments

Comments
 (0)