Skip to content

Commit 638ac5f

Browse files
tianyicuiclaude
andcommitted
feat: expose --reconnection-grace-time CLI flag
Pass through VS Code Server's --reconnection-grace-time argument, allowing users to configure how long the server waits for a disconnected client to reconnect before cleaning up the session. This is useful for users whose client machines sleep overnight, causing the default 3-hour grace period to expire and forcing a "Reload Window" on wake. The flag can also be set via $CS_RECONNECTION_GRACE_TIME env var or in config.yaml. Fixes #7665 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9184b64 commit 638ac5f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/node/cli.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface UserProvidedCodeArgs {
5252
"disable-workspace-trust"?: boolean
5353
"disable-getting-started-override"?: boolean
5454
"disable-proxy"?: boolean
55+
"reconnection-grace-time"?: string
5556
"session-socket"?: string
5657
"cookie-suffix"?: string
5758
"link-protection-trusted-domains"?: string[]
@@ -315,6 +316,12 @@ export const options: Options<Required<UserProvidedArgs>> = {
315316
type: "number",
316317
description: "Timeout in seconds to wait before shutting down when idle.",
317318
},
319+
"reconnection-grace-time": {
320+
type: "string",
321+
description:
322+
"Override the reconnection grace time in seconds. Clients who disconnect for longer than this duration will need to \n" +
323+
"reload the window. Defaults to 10800 (3 hours).",
324+
},
318325
}
319326

320327
export const optionDescriptions = (opts: Partial<Options<Required<UserProvidedArgs>>> = options): string[] => {
@@ -631,6 +638,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
631638
args["github-auth"] = process.env.GITHUB_TOKEN
632639
}
633640

641+
if (process.env.CS_RECONNECTION_GRACE_TIME) {
642+
args["reconnection-grace-time"] = process.env.CS_RECONNECTION_GRACE_TIME
643+
}
644+
634645
if (process.env.CODE_SERVER_IDLE_TIMEOUT_SECONDS) {
635646
if (isNaN(Number(process.env.CODE_SERVER_IDLE_TIMEOUT_SECONDS))) {
636647
logger.info("CODE_SERVER_IDLE_TIMEOUT_SECONDS must be a number")

test/unit/node/cli.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe("parser", () => {
4747
delete process.env.PASSWORD
4848
delete process.env.CS_DISABLE_FILE_DOWNLOADS
4949
delete process.env.CS_DISABLE_GETTING_STARTED_OVERRIDE
50+
delete process.env.CS_RECONNECTION_GRACE_TIME
5051
delete process.env.VSCODE_PROXY_URI
5152
delete process.env.CS_DISABLE_PROXY
5253
console.log = jest.fn()
@@ -114,6 +115,8 @@ describe("parser", () => {
114115

115116
["--session-socket", "/tmp/override-code-server-ipc-socket"],
116117

118+
["--reconnection-grace-time", "86400"],
119+
117120
["--host", "0.0.0.0"],
118121
"4",
119122
"--",
@@ -150,6 +153,7 @@ describe("parser", () => {
150153
version: true,
151154
"bind-addr": "192.169.0.1:8080",
152155
"session-socket": "/tmp/override-code-server-ipc-socket",
156+
"reconnection-grace-time": "86400",
153157
"abs-proxy-base-path": "/codeserver/app1",
154158
"skip-auth-preflight": true,
155159
})
@@ -456,6 +460,19 @@ describe("parser", () => {
456460
})
457461
})
458462

463+
it("should use env var CS_RECONNECTION_GRACE_TIME", async () => {
464+
process.env.CS_RECONNECTION_GRACE_TIME = "86400"
465+
const args = parse([])
466+
expect(args).toEqual({})
467+
468+
const defaultArgs = await setDefaults(args)
469+
expect(defaultArgs).toEqual({
470+
...defaults,
471+
"reconnection-grace-time": "86400",
472+
})
473+
delete process.env.CS_RECONNECTION_GRACE_TIME
474+
})
475+
459476
it("should error if password passed in", () => {
460477
expect(() => parse(["--password", "supersecret123"])).toThrowError(
461478
"--password can only be set in the config file or passed in via $PASSWORD",

0 commit comments

Comments
 (0)