diff --git a/lib/client.js b/lib/client.js index 55eefa7..11757d3 100644 --- a/lib/client.js +++ b/lib/client.js @@ -69,11 +69,15 @@ class Client { } message(data) { - const packet = JSON.parse(data); - const [callType, methodName] = Object.keys(packet); - const callId = packet[callType]; - const args = packet[methodName]; - this.rpc(callId, methodName, args); + try { + const packet = JSON.parse(data); + const [callType, methodName] = Object.keys(packet); + const callId = packet[callType]; + const args = packet[methodName]; + this.rpc(callId, methodName, args); + } catch (err) { + application.logger.error(err.message); + } } async rpc(callId, method, args) { diff --git a/test/system.js b/test/system.js index fffec46..dca0b1b 100644 --- a/test/system.js +++ b/test/system.js @@ -18,8 +18,8 @@ setTimeout(async () => { worker.postMessage({ name: 'stop' }); }, TEST_TIMEOUT); -worker.on('exit', () => { - console.log('System test finished'); +worker.on('exit', code => { + console.log(`System test finished with code ${code}`); }); const tasks = [ @@ -64,11 +64,12 @@ setTimeout(() => { const req = http.request(request); req.on('response', res => { const expectedStatus = task.status || 200; - assert.equal(res.statusCode, expectedStatus); + setTimeout(() => { + assert.equal(res.statusCode, expectedStatus); + }, TEST_TIMEOUT); }); req.on('error', err => { console.log(err.stack); - process.exit(1); }); if (task.data) req.write(task.data); req.end();