mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(realtime): bound the debug-log sink and stop blocking on its writes
Ported onto the split provider layout: the route now lives in server/providers/openai/debug-log.js and its state belongs to the handler the factory returns rather than to module scope. /api/realtime/debug-log is the one route in its family left unhardened. Both siblings enforce a limiter through openai/rate-limit.js, and this was the only handler still writing with fs.appendFileSync on the request path. - Always-on per-IP limiter (120/min, 400 global). Deliberately not the opt-in openAiRateLimiter(): that one defaults to unlimited so throttling cannot silently change what a user spends, and this sink spends disk and event-loop time rather than provider quota. - Serialized async appends with a 32 MB rotation ceiling and one retained generation. REALTIME_DEBUG_LOG_MAX_BYTES caps a single request body; it never bounded the file those bodies accumulate into, so any local page could grow .gev-logs/realtime-conversations.jsonl for as long as the dev server ran. Serializing also closes a read-then-write race on the size check, where concurrent callers all stat under the ceiling and none rotates. - Generic 400/500 answers separating a malformed record or oversized body from a failed write, instead of echoing error.message — an errno and an absolute path for an fs failure. - readRequestBody marks an oversized body with code 'BODY_TOO_LARGE', the marker its sibling readRequestBodyCapped already sets, so the two cases are distinguishable without matching on text. Coverage extends src/tooling/localServices.test.mjs, which already drives the real handler over a temporary sourceRoot. Both new tests fail on the previous implementation and pass with this one. Refs #23. Does not add authentication: these proxies have no auth mechanism today, so introducing one is a maintainer design decision.
This commit is contained in:
1 parent
96a6b49477
commit
44817e1286
5 files changed
+154
-16
No files matched your search
@@ -3201,6 +3201,7 @@ are omitted rather than framing the wrong part of the globe.
|
||||
- `/api/route` proxies bounded OSRM route requests for annotation routes, with profile allowlisting, distance caps, response caps, caching, and sanitized "no route found" errors.
|
||||
- Track endpoints: `/api/ais-live/track?mmsi=` (server-accumulated ring buffers; sub-route handled before the rows snapshot), `/api/opensky-track?icao24=` (OAuth, 60s cache, sanitized errors, independent OpenSky credit bucket), `/api/adsblol/trace?hex=` (60s cache, 5MB cap, ODbL attribution required in UI).
|
||||
- Realtime debug logs redact API keys, bearer tokens, client secrets, and image data URLs before writing to disk; request bodies are size-capped.
|
||||
- `/api/realtime/debug-log` enforces an always-on 120-per-client/400-global one-minute limiter (not the opt-in `GEV_RATELIMIT_OPENAI_PER_MIN` bucket the cost-bearing OpenAI routes share), appends asynchronously through a serialized queue, and rotates `realtime-conversations.jsonl` at 32 MB keeping one prior generation, so the sink is bounded at twice that regardless of session length. A malformed record answers 400 and a failed write 500, both with a fixed message.
|
||||
|
||||
## UI/UX Runtime Defaults
|
||||
|
||||
|
||||
Reference in new issue
Block a user