From bfd7e231243c6cb88fbe72cc23b5205d42c1053e Mon Sep 17 00:00:00 2001 From: nai-degen Date: Thu, 16 Nov 2023 01:18:55 -0600 Subject: [PATCH] encodes queue payload --- src/proxy/queue.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/proxy/queue.ts b/src/proxy/queue.ts index 584ef90..689805c 100644 --- a/src/proxy/queue.ts +++ b/src/proxy/queue.ts @@ -473,6 +473,14 @@ function removeProxyMiddlewareEventListeners(req: Request) { export function registerHeartbeat(req: Request) { const res = req.res!; + const currentSize = getHeartbeatSize(); + req.log.info({ + currentSize, + HEARTBEAT_INTERVAL, + PAYLOAD_SCALE_FACTOR, + MAX_HEARTBEAT_SIZE, + }, "Joining queue with heartbeat."); + let isBufferFull = false; let bufferFullCount = 0; req.heartbeatInterval = setInterval(() => { @@ -542,8 +550,9 @@ function getHeartbeatPayload() { const size = getHeartbeatSize(); const data = process.env.NODE_ENV === "production" - ? crypto.randomBytes(size) + ? crypto.randomBytes(size).toString("base64") : `payload size: ${size}`; + return `: queue heartbeat ${data}\n\n`; }