Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions test/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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();
Expand Down