Skip to content

Add a test for the --idle-timeout-seconds shutdown - #8156

Merged
code-asher merged 1 commit into
coder:mainfrom
Trenyx:test/idle-timeout-seconds
Dec 2, 2026
Merged

code-asher merged 1 commit into
coder:mainfrom
Trenyx:test/idle-timeout-seconds

Conversation

@Trenyx

@Trenyx Trenyx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

No linked issue: this PR only adds a test.

If the idle shutdown timer ever lost its * 1000, --idle-timeout-seconds 3600 would shut code-server down after 3.6 seconds of idleness instead of an hour, and no test would notice.

Tests only: one test (+42 lines) in test/unit/node/main.test.ts. No change to library code.

What the test pins

--idle-timeout-seconds is documented as "Timeout in seconds to wait before shutting down when idle." No unit test runs the timer in runCodeServer. The new test starts runCodeServer with --idle-timeout-seconds=120 under fake timers, with createApp and register mocked as in the existing tests and a heart that never reports activity, and checks that wrapper.exit is not called after 119 seconds and is called with 0 at 120 seconds.

How it was checked

On main c094099c:

  • ./test/node_modules/.bin/jest --coverage=false test/unit/node/main.test.ts: 5 passed (the new one included).
  • pnpm run test:unit: all 23 suites pass.
  • prettier --check and eslint --max-warnings=0 on the file are clean.
  • With }, args["idle-timeout-seconds"]! * 1000) changed to }, args["idle-timeout-seconds"]!) in src/node/main.ts, this new test is the only one that fails (4 pass, 1 fails: wrapper.exit called before 119 seconds); the rest of test/unit still passes.

This test was written with Claude Code during a planted-bug run by SK @ Trenyx.

No unit test ran the idle shutdown timer, so dropping the seconds to
milliseconds conversion would make --idle-timeout-seconds 3600 shut
code-server down after 3.6 seconds and every test would still pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Trenyx
Trenyx requested a review from a team as a code owner November 24, 2026 22:31

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@code-asher
code-asher merged commit 7886903 into coder:main Dec 2, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants