From 165345b098db92ca2b365afbebca77dfb49c97a6 Mon Sep 17 00:00:00 2001 From: Niklas Bauer Date: Fri, 22 Dec 2023 11:21:55 +0100 Subject: [PATCH] Read chunked data from companion server (#402) --- src/companion.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/companion.ts b/src/companion.ts index e2ccddb..c500c16 100644 --- a/src/companion.ts +++ b/src/companion.ts @@ -98,12 +98,9 @@ export const setupCompanionServer = () => { const { headers } = req; let rawProblem = ''; - req.on('readable', function () { + req.on('data', (chunk) => { COMPANION_LOGGING && console.log('Companion server got data'); - const tmp = req.read(); - if (tmp && tmp != null && tmp.length > 0) { - rawProblem += tmp; - } + rawProblem += chunk; }); req.on('close', function () { try { @@ -112,7 +109,9 @@ export const setupCompanionServer = () => { COMPANION_LOGGING && console.log('Companion server closed connection.'); } catch (e) { - // Ignore + vscode.window.showErrorMessage( + `Error parsing problem from companion "${e}"`, + ); } }); res.write(JSON.stringify(savedResponse));