From 2165afcc02dcdcaa94ec1943768f3b61a8900d12 Mon Sep 17 00:00:00 2001 From: seb Date: Fri, 16 Oct 2026 01:40:32 +0200 Subject: [PATCH] u --- src/api/routes/company.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api/routes/company.js b/src/api/routes/company.js index 042be86..2aac755 100644 --- a/src/api/routes/company.js +++ b/src/api/routes/company.js @@ -552,14 +552,19 @@ export function register(app, basePath = '') { res.setTimeout?.(0); req.socket?.setNoDelay(true); - res.setHeader('Content-Type', 'text/event-stream'); - res.setHeader('Cache-Control', 'no-cache, no-transform'); - res.setHeader('Connection', 'keep-alive'); - res.setHeader('X-Accel-Buffering', 'no'); + res.writeHead(200, { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache, no-transform', + 'Connection': 'keep-alive', + 'X-Accel-Buffering': 'no', + }); if (typeof res.flushHeaders === 'function') { res.flushHeaders(); } + // Initial ping to establish frame through any proxy + res.write(': ping\n\n'); + req.on('close', () => { console.warn(`[Company Import SSE] Client request closed (writableEnded: ${res.writableEnded}, destroyed: ${res.destroyed})`); }); @@ -584,6 +589,7 @@ export function register(app, basePath = '') { } res.write(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`); if (typeof res.flush === 'function') res.flush(); + if (typeof req.socket?.uncork === 'function') req.socket.uncork(); }; sseWrite('status', { message: 'Import gestartet. Daten werden verarbeitet...' });