fix(chat): add SSE padding to bypass proxy buffering

This commit is contained in:
mstfyldz
2026-08-12 12:48:04 +03:00
parent 7b6b27909c
commit d10ea1b0fd
2 changed files with 17 additions and 0 deletions
+8
View File
@@ -33,10 +33,18 @@ function startSse(res: Response) {
// toplu halde göndermesini önlemek için.
res.setHeader('X-Accel-Buffering', 'no');
(res as any).flushHeaders?.();
// Cloudflare gibi proxy'lerin buffer'ını aşmak için ~2KB dummy padding gönder.
res.write(`: ${' '.repeat(2048)}\n\n`);
if (typeof (res as any).flush === 'function') {
(res as any).flush();
}
}
function sseWrite(res: Response, payload: Record<string, unknown>) {
res.write(`data: ${JSON.stringify(payload)}\n\n`);
if (typeof (res as any).flush === 'function') {
(res as any).flush();
}
}
interface ChatAttachment { filename: string; text: string; }
+9
View File
@@ -0,0 +1,9 @@
require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_ROLE_KEY);
async function run() {
const { data, error } = await supabase.from('analyses').select('*').order('created_at', { ascending: false }).limit(3);
console.log(JSON.stringify(data, null, 2));
console.error(error);
}
run();