Skip to content

Commit

Permalink
Don't let JSON errors crash client
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Feb 6, 2011
1 parent f46a239 commit 3150ed0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ var Worker = function (options) {
return self.emit('error', error);
}

var data = JSON.parse(Buffer.isBuffer(data[1]) ? data[1].toString() : data),
job = new Job(self, data);
try {
data = JSON.parse(Buffer.isBuffer(data[1]) ? data[1].toString() : data[1]);
var job = new Job(self, data);

self.emit('message', job);
self.emit('message', job);
} catch (json_error) {}

if (!self.client.quitting && self.continual) {
// Listen for more jobs.
Expand Down

0 comments on commit 3150ed0

Please sign in to comment.