Repository navigation
test(daemon): the OS process lookup tests pass on a loaded Windows machine - #2842
Merged
Merged
Conversation
…chine daemon-lock-holder.test.ts > "reads a running process from the OS" failed under load on Windows, and so did the seven CLI tests in the file that look a process up. describeProcess gives each OS query 5 s: on a busy machine PowerShell takes longer than that to start and run its CIM query, so the lookup falls back to tasklist (the image name only, or nothing once tasklist runs out too) and the command line is null. The in-process test's toMatch(/ping/) then fails, and the CLI the other tests spawn sees a Node holder it can't classify, keeps the lock, and says so. In production that fallback is the intended fail-safe: an undescribed holder stays "unknown" and its lock is kept. The per-query budget is still 5 s unless CODEGRAPH_PROCESS_LOOKUP_TIMEOUT_MS says otherwise, and nothing outside the tests sets it. The test file sets it to 60 s for itself and for every CLI it spawns (an env var reaches both), gives the lookup tests time to match (240 s per CLI run, 30 s for a killed holder to go), and adds a Windows-only test that a lookup that runs out says nothing, so the holder stays "unknown". Validation (Windows, 16 logical CPUs, a 48-thread CPU burn running): - describeProcess on a live PING.EXE: the 5 s budget answered nothing in 8 of 8 lookups (about 11 s each); a 60 s budget read the command line in 6 of 6 (median 12.6 s, max 13.6 s). - The reported test alone: main 0 of 4, each "expected '' to match /ping/i"; this branch 2 of 2, and 6 of 6 with an earlier revision that passed the same 60 s budget as an argument. - The whole file: main 3 of 11, the 8 failures being exactly the tests that look a process up; this branch 12 of 12, twice. - No load: 12 of 12 in 20 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__tests__/daemon-lock-holder.test.ts› "reads a running process from the OS" failed on a loaded Windows machine. So, under the same load, did the seven CLI tests in the file that look a process up. They now pass under load. Production behaviour is unchanged.Root cause
describeProcess(src/mcp/process-identity.ts) gives each OS query 5 s. On Windows it asks PowerShell'sGet-CimInstance Win32_Processfor the command line, and when that fails or runs out of time, it falls back totasklist, which only has the image name. On a busy machine, PowerShell takes longer than 5 s to start and answer. The command line is thennull, and the test'stoMatch(/ping/)fails. Under heavier loadtasklistruns out too, and the lookup returns nothing at all.The seven CLI tests hit the same budget inside the
codegraph index/codegraph unlockthey spawn. A Node holder is classified only by its command line, so without one it staysunknown, the lock is kept, and the test sees "could not tell what it is" instead of a cleared lock.In production that fallback is the intended fail-safe. A holder the OS won't describe stays
unknown, its lock is kept, and the message says how to clear it by hand. Nothing there changes.Fix
process-identity.ts. The per-query budget is still 5 s, unlessCODEGRAPH_PROCESS_LOOKUP_TIMEOUT_MSsays otherwise. Nothing sets it outside the tests. An env var rather than a parameter, because the CLI tests need it inside the CLI processes they spawn, and the env reaches both those and the in-process test.daemon-lock-holder.test.ts.afterAll), so it reaches the in-process lookups and every CLI the file runs.runCliallows 240 s per CLI run, and the waits for a killed holder go from 10 s to 30 s. At normal load the file still takes about 20 s.unknown. That is the fail-safe the production path relies on, and the test also proves the override is read.There is no CHANGELOG bullet: nothing a user sees changes. Earlier test-only fixes (#2772, #2629) had none either.
Validation
Windows 11, 16 logical CPUs. "Burn" means a 48-thread CPU-burn loop (
nodeworker threads spinning) running alongside, started on an otherwise idle gate.describeProcesson a livePING.EXE, under burnexpected '' to match /ping/iOne more single-test run of this branch under the burn never loaded its test file: vitest's own module fetch timed out. It's left out of the counts.
Suite. The full suite was run on the pushed commit 3b10207, with
CODEGRAPH_KERNEL_EXPECT=1and the kernel built. It covered 751 files (745 passed, 6 skipped) and 8,983 tests: 8,901 passed, 0 failed, 82 skipped, with no reruns.Left out
codegraph indexwait longer on a loaded machine before it falls back to the fail-safe it already has.🤖 Generated with Claude Code