Skip to content

fix(turbo): limit concurrency on Windows to prevent tsgo OOM - #49228

Open
AndyS77 wants to merge 1 commit into
anomalyco:devfrom
AndyS77:turbo-concurrency-limit
Open

AndyS77 wants to merge 1 commit into
anomalyco:devfrom
AndyS77:turbo-concurrency-limit

Conversation

@AndyS77

@AndyS77 AndyS77 commented Sep 15, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #49224

Type of change

  • Bug fix

What does this PR do?

tsgo crashes with fatal error: out of memory (errno=1455) when bun turbo typecheck runs 30 packages in parallel on heavily loaded Windows machines. The Go runtime allocates ~84 MB committed memory per process during startup; with 30 parallel processes the combined spike can exceed the remaining commit budget (RAM + pagefile).

This PR adds script/turbo.ts that calculates safe concurrency at runtime:

concurrency = max(1, min(cpuCount, floor(freeMB / 100)))

Windows-only; other platforms pass through to turbo unchanged. The 100 MB per-process estimate is derived from the measured 84 MB peak, rounded up for safety margin.

How did you verify your code works?

  • Ran bun run script/turbo.ts typecheck on Windows 11 (8 CPUs, 3.4 GB free commit): output shows concurrency=8 (cpus=8, free=3402MB) — no OOM crash, only genuine TS errors
  • Previously without the limit: all 30 tasks crashed with errno=1455 when system was at 94% commit
  • With --concurrency=4 and >400 MB free: no OOM crashes

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

tsgo crashes with fatal error: out of memory (errno=1455) when turbo runs
30 typecheck tasks in parallel on heavily loaded Windows machines. The Go
runtime allocates ~84 MB committed memory per process during startup; with
30 parallel processes the combined spike can exceed the remaining commit
budget (RAM + pagefile).

Add script/turbo.ts that calculates safe concurrency at runtime:
  concurrency = max(1, min(cpuCount, floor(freeMB / 100)))

Windows-only; other platforms pass through to turbo unchanged.

Closes anomalyco#49224

Co-Authored-By: opencode <opencode@anomaly.co>
Agent: @bug-fix
Model: msp-crow/zai-glm-52
Scope: anomalyco#49224
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

tsgo crashes with OOM on Windows when turbo typecheck runs in parallel on heavily loaded machines

1 participant