Files
ngit-grasp/src/http
DanConwayDev f55ce4885b fix(metrics): isolate scrape rendering from async workers
Each metrics scrape traverses repository directories and encodes the
response synchronously. Slow filesystem metadata operations could occupy
a worker that also serves WebSocket and Git requests.

Render on a blocking worker. Acquire a shared permit before spawning it
and keep that permit inside the worker even if the HTTP request is
canceled, so concurrent scrapes cannot start overlapping directory scans.
Report a worker failure as an HTTP 500 response rather than losing the
request task.

Preserve the synchronous rendering API, metric contents and monitoring
configuration. This does not cache metrics or claim a measured production
speedup; it prevents scrape work from running on the async executor.

Validation: a current-thread test checks that a queued scrape yields,
capacity is released and async rendering preserves repository counts.
2026-09-14 10:05:48 +00:00
..