Skip to content

Commit 9884812

Browse files
committed
Move socket check after window flags
These flags mean the user explicitly wants to open in an existing instance so if the socket is down it should error rather than try to spawn code-server normally.
1 parent 6cb6d6c commit 9884812

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/node/cli.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,6 @@ export const shouldOpenInExistingInstance = async (
762762
const paths = getResolvedPathsFromArgs(args)
763763
const client = new EditorSessionManagerClient(sessionSocket)
764764

765-
// If we can't connect to the socket then there's no existing instance.
766-
if (!(await client.canConnect())) {
767-
return undefined
768-
}
769-
770765
// If these flags are set then assume the user is trying to open in an
771766
// existing instance since these flags have no effect otherwise.
772767
const openInFlagCount = ["reuse-window", "new-window"].reduce((prev, cur) => {
@@ -783,6 +778,9 @@ export const shouldOpenInExistingInstance = async (
783778
// 2. That a file or directory was passed.
784779
// 3. That the socket is active.
785780
if (Object.keys(args).length === 1 && typeof args._ !== "undefined" && args._.length > 0) {
781+
if (!(await client.canConnect())) {
782+
return undefined
783+
}
786784
const socketPath = await client.getConnectedSocketPath(paths[0])
787785
if (socketPath) {
788786
logger.debug("Found existing code-server socket")

0 commit comments

Comments
 (0)