Skip to content

Release v0.55.24: shorter GC stalls, no 502 on reused backend connections - #2001

Open
helpcodeai wants to merge 3 commits into
mainfrom
perf/cloud-gc-keepalive
Open

helpcodeai wants to merge 3 commits into
mainfrom
perf/cloud-gc-keepalive

Conversation

@helpcodeai

@helpcodeai helpcodeai commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Release v0.55.24. This PR carries the version bump (0.55.23 → 0.55.24 in the three package.json files, package-lock.json and server.json) together with the change below, to save one CI cycle. It merges last, after #1998, #1999 and #2000; the release also contains #1995, #1996 and #1997, which are already on main.

On 2026-12-06 at 07:36 UTC the Cloud uptime probe reported one minute of downtime. The backend never restarted. A garbage collection froze its event loop for about 8 s, and the probe's /mcp/demo call then went out on an upstream connection the backend had just closed: Caddy answered 502 (connection reset by peer). It was the only 5xx of that minute (714 requests), but 49 requests took over 5 s.

One week of vitals log lines (19,757 samples) shows the pattern behind it:

Window Samples with a stall > 1 s > 3 s > 5 s Worst
Night Fri-Sat, 4 GB heap 107 3 0 3.9 s
Night Sat-Sun, 6 GB heap 93 16 7 8.4 s
Saturday 10-20 UTC, 4 GB heap 324 (27 %) 20 1 5.9 s

A bigger heap did not reduce the stalled time. It moved it into fewer, longer freezes. The stalls follow old-space collections (median 1.0 s at 4 GB and 1.7 s at 6 GB when the heap drops by more than 600 MB between two samples; 0.14-0.36 s otherwise). The old space fills fast because V8's default 16 MB young generation promotes the garbage of every tool call.

Changes

  • Caddy (Cloud): idle connections to the backend and the frontend are dropped after 55 s, before the app closes them. Removes the reused-connection 502.
  • Frontend (Cloud): KEEP_ALIVE_TIMEOUT=65000, as the backend has. Next's standalone server closed idle connections after 5 s; three POSTs to the frontend got a 502 from that in the last 36 h.
  • start.sh: new opt-in NODE_MAX_SEMI_SPACE_MB (digits only; unset or 0 keeps V8's default) passed as --max-semi-space-size.
  • docker-compose.cloud.yml: Cloud default NODE_MAX_SEMI_SPACE_MB=64.
  • Vitals log line: new gc block with count, total and longest pause per kind (major, minor, incremental) since the previous line, from a PerformanceObserver. The next heap or semi-space change can then be measured.
  • .env.example: the new variable.

Deployment modes: self-hosted keeps V8's defaults unless the operator sets NODE_MAX_SEMI_SPACE_MB; it gets the gc block in the vitals line. The Caddyfile and the compose default are Cloud only.

Not in this PR: the Cloud heap limit itself (NODE_MAX_OLD_SPACE_MB in the server .env) goes from 6144 to 5120 with the deploy, to cap the size of one collection while keeping more room than 4 GB gave by day.

Type

  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Performance improvement
  • Other (describe below)

Testing

  • Added/updated unit tests

  • Tested manually (describe steps below)

  • No tests needed (explain why)

  • packages/backend: npx jest --maxWorkers=4 src/common/process-vitals.spec.ts: 32 passed (3 new). npx tsc --noEmit -p tsconfig.json: no errors. npx eslint on the three changed files: no findings.

  • Caddyfile: adapted with the production Caddy binary (caddy adapt, read-only): all 28 reverse_proxy handlers (24 backend, 4 frontend) carry keep_alive.idle_timeout 55 s. The frontend's server.js in the running image reads KEEP_ALIVE_TIMEOUT.

  • start.sh: sh -n passes; the flag logic gives no flag for unset, 0, abc, 6x4 and --max-semi-space-size=64 for 64. Node 26 starts with the flag.

  • GC observer checked on Node 26.13: gc entries carry detail.kind.

Checklist

  • My code follows the existing code style
  • I have tested my changes locally
  • I have updated documentation (if applicable)
  • All existing tests pass (npm test)
  • This PR has a descriptive title

Related Issues

Found in the 2026-12-06 daily check.

@helpcodeai helpcodeai changed the title Shorten GC stalls on Cloud and stop 502s on reused backend connections Release v0.55.24: shorter GC stalls, no 502 on reused backend connections Dec 6, 2026

This branch has not been deployed

No deployments
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.

1 participant