Skip to content

Commit 5a45855

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 d544846 commit 5a45855

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[] => {
@@ -632,6 +639,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
632639
args["github-auth"] = process.env.GITHUB_TOKEN
633640
}
634641

642+
if (process.env.CS_RECONNECTION_GRACE_TIME) {
643+
args["reconnection-grace-time"] = process.env.CS_RECONNECTION_GRACE_TIME
644+
}
645+
635646
if (process.env.CODE_SERVER_IDLE_TIMEOUT_SECONDS) {
636647
if (isNaN(Number(process.env.CODE_SERVER_IDLE_TIMEOUT_SECONDS))) {
637648
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
@@ -48,6 +48,7 @@ describe("parser", () => {
4848
delete process.env.PASSWORD
4949
delete process.env.CS_DISABLE_FILE_DOWNLOADS
5050
delete process.env.CS_DISABLE_GETTING_STARTED_OVERRIDE
51+
delete process.env.CS_RECONNECTION_GRACE_TIME
5152
delete process.env.VSCODE_PROXY_URI
5253
delete process.env.CS_DISABLE_PROXY
5354
console.log = jest.fn()
@@ -115,6 +116,8 @@ describe("parser", () => {
115116

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

119+
["--reconnection-grace-time", "86400"],
120+
118121
["--host", "0.0.0.0"],
119122
"4",
120123
"--",
@@ -151,6 +154,7 @@ describe("parser", () => {
151154
version: true,
152155
"bind-addr": "192.169.0.1:8080",
153156
"session-socket": "/tmp/override-code-server-ipc-socket",
157+
"reconnection-grace-time": "86400",
154158
"abs-proxy-base-path": "/codeserver/app1",
155159
"skip-auth-preflight": true,
156160
})
@@ -457,6 +461,19 @@ describe("parser", () => {
457461
})
458462
})
459463

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

0 commit comments

Comments
 (0)