Skip to content

Commit

Permalink
Read chunked data from companion server (agrawal-d#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNiklas authored Dec 22, 2023
1 parent a912081 commit 165345b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/companion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
Expand Down

0 comments on commit 165345b

Please sign in to comment.