Adjust chunked transfer to send 4KB (CF's buffer size) of data every 49 seconds

This commit is contained in:
user
2024-12-31 08:23:45 +00:00
parent b00fb88cab
commit e2b602fd52
+3 -3
View File
@@ -196,15 +196,15 @@ const setupChunkedTransfer: RequestHandler = (req, res, next) => {
// Higher values are required - otherwise Cloudflare will buffer and not pass
// the separate chunks, which means that a >100s response will get terminated anyway
const keepAlive = setInterval(() => {
res.write(' '.repeat(512));
}, 5_000);
res.write(' '.repeat(4096));
}, 49_000);
(req as any)._keepAliveInterval = keepAlive;
}
next();
};
// General chat completion endpoint. Turbo-instruct is not supported here.
openaiRouter.post(
"/v1/chat/completions",
ipLimiter,