From a80c9eb37a80d2edec69835264c83ae2dd983c46 Mon Sep 17 00:00:00 2001 From: ItsNiklas Date: Thu, 21 Dec 2023 00:52:16 +0100 Subject: [PATCH] Read chunked data from companion server --- 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));