fix(live): return 502 and prevent caching on oversized track responses (fixes #720)

This commit is contained in:
Raushankumar0720 committed 2026-09-23 15:52:21 +05:30
1 parent 082074a006
commit 34d258b394
2 files changed
+44 -2

No files matched your search

+6 -2
View File
@@ -45,7 +45,9 @@ export function trackBackfillProxies() {
RESPONSE_CAP_BYTES,
);
let body;
let status = upstream.status;
if (tooLarge) {
status = 502;
body = JSON.stringify({ error: 'Upstream track response too large' });
} else if (!upstream.ok) {
// Sanitize upstream error surface; status code is signal enough
@@ -53,8 +55,10 @@ export function trackBackfillProxies() {
} else {
body = text;
}
cachePut(key, { at: Date.now(), status: upstream.status, body });
res.statusCode = upstream.status;
if (!tooLarge) {
cachePut(key, { at: Date.now(), status, body });
}
res.statusCode = status;
res.setHeader('Content-Type', 'application/json; charset=utf-8');
res.setHeader('Cache-Control', 'no-store');
res.end(body);