From b89fd8d2797077725ea0dbf17ce4e1a468b1da7a Mon Sep 17 00:00:00 2001 From: Raju Date: Tue, 24 Mar 2026 13:08:13 +0530 Subject: [PATCH] fix[notask]: add 1 MB request body size limit to TTS benchmark server The TTS benchmark server processJsonRequest() accumulated the entire request body without any size limit. A single large POST could exhaust server memory. Add a 1 MB cap consistent with the whisper benchmark server implementation. Made-with: Cursor --- .../benchmarks/server/src/utils/helper.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/qvac-lib-infer-onnx-tts/benchmarks/server/src/utils/helper.js b/packages/qvac-lib-infer-onnx-tts/benchmarks/server/src/utils/helper.js index 5baedd3ba2..fa849c7c8f 100644 --- a/packages/qvac-lib-infer-onnx-tts/benchmarks/server/src/utils/helper.js +++ b/packages/qvac-lib-infer-onnx-tts/benchmarks/server/src/utils/helper.js @@ -2,18 +2,26 @@ const Buffer = require('bare-buffer') +const MAX_BODY_SIZE = 1 * 1024 * 1024 // 1 MB + /** * Process incoming JSON request body */ async function processJsonRequest (req) { return new Promise((resolve, reject) => { const chunks = [] + let received = 0 req.on('data', chunk => { + received += chunk.length + if (received > MAX_BODY_SIZE) { + req.destroy(new Error('Payload too large')) + return + } chunks.push(chunk) }) req.on('end', () => { try { - const buffer = Buffer.concat(chunks) + const buffer = Buffer.concat(chunks, received) const body = JSON.parse(buffer.toString()) resolve(body) } catch (err) {