Skip to content

VS Code: Stop charging Node startup to the Project Analysis timeout - #2553

Merged
marcoroth merged 2 commits into
marcoroth:mainfrom
assirims:vscode-analysis-worker-timeout
Sep 14, 2026
Merged

marcoroth merged 2 commits into
marcoroth:mainfrom
assirims:vscode-analysis-worker-timeout

Conversation

@assirims

@assirims assirims commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #2552.

Problem

Project Analysis in the VS Code extension spawns a fresh Node process per file (os.cpus().length at once) and kills each after 1 s. Every worker first has to boot Node and load the WASM bundle before it reads the file: ~0.45 s on an idle Apple Silicon Mac, ~0.7 s with the formatter enabled. Under any CPU contention most of a large project is reported as "Timed Out". On a 460-template Rails app the count was 452, 238 and 275 on the same tree, tracking machine load rather than the files; the native parser needs at most 24 ms on the largest template.

Change

  • analysis-service.ts — the process-level limit becomes a 30 s hang guard (WORKER_TIMEOUT_MS) with a comment on why it must not be tight. The parse itself is already bounded by ParserOptions.timeout (1 s by default), so runaway parses are still caught.
  • parse-worker.js — reports timedOut: true when the parse result carries a TIMEOUT_ERROR, and the service maps that to the timeout status. The "Timed Out" group therefore keeps meaning "the parser gave up on this file" rather than "Node did not finish booting".

No new settings, no change to the worker's arguments.

Verification

  • With the bundled extension.js patched to the same larger timeout, all 460 files pass Project Analysis on the machine that reported the timeouts.
  • node --check on the worker; the TypeScript change is a constant, one option, and one ternary.
  • I could not run the monorepo build locally (it needs the native toolchain), so CI is the typecheck here.

🤖 Generated with Claude Code

Project Analysis spawns a fresh Node process per file, cpus() of them at
once, and kills each after 1 s. A worker has to boot Node and load the
WASM bundle before it reads the file, about half a second on an idle
Apple Silicon Mac, so under any contention most of a large project was
reported as "Timed Out" although the native parser needs at most 24 ms
on the largest template.

The parse is already bounded by ParserOptions.timeout (1 s by default),
which surfaces as a TIMEOUT_ERROR in the result. So the process limit
only has to catch a hung worker: it is now 30 s, and the worker reports
a parser timeout as `timedOut` so the "Timed Out" group keeps meaning
"the parser gave up on this file".

Fixes marcoroth#2552

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 5, 2026 18:58
@github-actions github-actions Bot added javascript JavaScript source across the javascript/ packages vscode VS Code editor support typescript TypeScript source across the javascript/ packages labels Sep 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are small, consistent with existing error-type conventions, and align the timeout status with parser timeouts while avoiding false positives from worker startup latency.

Pull request overview

This PR adjusts the VS Code extension’s Project Analysis worker management so that “Timed Out” reflects parser-level timeouts (via TIMEOUT_ERROR) rather than Node/WASM startup overhead, and increases the process-level timeout to act as a hang guard instead of a tight per-file budget.

Changes:

  • Increase the worker process timeout in AnalysisService to a 30s hang guard (WORKER_TIMEOUT_MS) and document why it must be generous.
  • Have parse-worker.js surface a timedOut flag when the parse produced a TIMEOUT_ERROR, and map that flag to the timeout status in the service.
File summaries
File Description
javascript/packages/vscode/src/analysis-service.ts Raises the exec timeout to a hang guard and maps worker-reported parse timeouts to the timeout file status.
javascript/packages/vscode/src/parse-worker.js Detects TIMEOUT_ERROR among recursive parse errors and reports timedOut in the worker result JSON.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread javascript/packages/vscode/src/analysis-service.ts Outdated
Co-authored-by: Marco Roth <marco.roth@intergga.ch>
Signed-off-by: Marco Roth <marco.roth@intergga.ch>
@marcoroth
marcoroth enabled auto-merge (squash) September 14, 2026 19:37
@marcoroth
marcoroth disabled auto-merge September 14, 2026 19:37
@marcoroth
marcoroth merged commit a840880 into marcoroth:main Sep 14, 2026
1 check passed

@marcoroth marcoroth left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @assirims!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript JavaScript source across the javascript/ packages typescript TypeScript source across the javascript/ packages vscode VS Code editor support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project Analysis: per-file 1 s spawn timeout counts Node/WASM startup, so most files show as Timed Out

3 participants