fix: use CODE_SERVER_ reconnection grace time env var

This commit is contained in:
Tianyi Cui 2026-03-24 13:41:11 +08:00
parent 5a458559ba
commit 12da14d62d
3 changed files with 17 additions and 6 deletions

View file

@ -22,6 +22,7 @@
- [How do I debug issues with code-server?](#how-do-i-debug-issues-with-code-server)
- [What is the healthz endpoint?](#what-is-the-healthz-endpoint)
- [What is the heartbeat file?](#what-is-the-heartbeat-file)
- [How do I change the reconnection grace time?](#how-do-i-change-the-reconnection-grace-time)
- [How do I change the password?](#how-do-i-change-the-password)
- [Can I store my password hashed?](#can-i-store-my-password-hashed)
- [Is multi-tenancy possible?](#is-multi-tenancy-possible)
@ -326,6 +327,16 @@ If you want to shutdown code-server if there hasn't been an active connection
after a predetermined amount of time, you can use the --idle-timeout-seconds flag
or set an `CODE_SERVER_IDLE_TIMEOUT_SECONDS` environment variable.
## How do I change the reconnection grace time?
Pass `--reconnection-grace-time <seconds>` to `code-server`, set
`CODE_SERVER_RECONNECTION_GRACE_TIME=<seconds>`, or add
`reconnection-grace-time: <seconds>` to
`~/.config/code-server/config.yaml`.
The default is `10800` (3 hours). If a client stays disconnected longer than
this, it must reload the window.
## How do I change the password?
Edit the `password` field in the code-server config file at

View file

@ -639,8 +639,8 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
args["github-auth"] = process.env.GITHUB_TOKEN
}
if (process.env.CS_RECONNECTION_GRACE_TIME) {
args["reconnection-grace-time"] = process.env.CS_RECONNECTION_GRACE_TIME
if (process.env.CODE_SERVER_RECONNECTION_GRACE_TIME) {
args["reconnection-grace-time"] = process.env.CODE_SERVER_RECONNECTION_GRACE_TIME
}
if (process.env.CODE_SERVER_IDLE_TIMEOUT_SECONDS) {

View file

@ -48,7 +48,7 @@ describe("parser", () => {
delete process.env.PASSWORD
delete process.env.CS_DISABLE_FILE_DOWNLOADS
delete process.env.CS_DISABLE_GETTING_STARTED_OVERRIDE
delete process.env.CS_RECONNECTION_GRACE_TIME
delete process.env.CODE_SERVER_RECONNECTION_GRACE_TIME
delete process.env.VSCODE_PROXY_URI
delete process.env.CS_DISABLE_PROXY
console.log = jest.fn()
@ -461,8 +461,8 @@ describe("parser", () => {
})
})
it("should use env var CS_RECONNECTION_GRACE_TIME", async () => {
process.env.CS_RECONNECTION_GRACE_TIME = "86400"
it("should use env var CODE_SERVER_RECONNECTION_GRACE_TIME for reconnection grace time", async () => {
process.env.CODE_SERVER_RECONNECTION_GRACE_TIME = "86400"
const args = parse([])
expect(args).toEqual({})
@ -471,7 +471,7 @@ describe("parser", () => {
...defaults,
"reconnection-grace-time": "86400",
})
delete process.env.CS_RECONNECTION_GRACE_TIME
delete process.env.CODE_SERVER_RECONNECTION_GRACE_TIME
})
it("should error if password passed in", () => {