Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
fix(NddService): fix NddService socket.on('data') for large input
Browse files Browse the repository at this point in the history
This patch fixes NddService.server socker.on('data') so that it can handle large amounts of input without throwing `SyntaxError: Unexpected end of JSON input` errors.

Fixes #319
  • Loading branch information
razorman8669 committed Oct 10, 2020
1 parent ade2052 commit 309810c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions services/ndd_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,22 @@ class NddService {
const pipeName = `node-ndb.${process.pid}.sock`;
this._pipe = path.join(pipePrefix, pipeName);
const server = net.createServer(socket => {
let chunks = [];
socket.on('data', async d => {
const runSession = await this._startSession(JSON.parse(d), frontend);
chunks.push(d)
});
socket.on('end', async () => {
let data = Buffer.concat(chunks);
const runSession = await this._startSession(JSON.parse(data), frontend);
socket.write('run');
runSession();
});
})
socket.on('error', e => caughtErrorDebug(e));
}).listen(this._pipe);
server.unref();
}


dispose() {
process.disconnect();
}
Expand Down

0 comments on commit 309810c

Please sign in to comment.