Skip to content

Commit

Permalink
be more safer when trying to freeze objects
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Oct 16, 2015
1 parent f3c516a commit 001218e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ worker.prototype.perform = function(job, callback) {
// To help with this, we can stry to make the inputs to the job immutible
// https://github.com/taskrabbit/node-resque/issues/99
// Note: if an input is a string or a number, you CANNOT freeze it saddly.
for(var i in combinedInputs){ Object.freeze(combinedInputs[i]); }
for(var i in combinedInputs){
if(typeof combinedInputs[i] === 'object'){
Object.freeze(combinedInputs[i]);
}
}

cb.apply(self, combinedInputs);
}
Expand Down
2 changes: 1 addition & 1 deletion test/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('worker', function(){
describe('integration', function(){

beforeEach(function(done){
worker = new specHelper.NR.worker({connection: specHelper.connectionDetails, timeout: specHelper.timeout, queues: specHelper.queue}, jobs)
worker = new specHelper.NR.worker({connection: specHelper.connectionDetails, timeout: specHelper.timeout, queues: specHelper.queue}, jobs);
worker.connect(done);
});

Expand Down

0 comments on commit 001218e

Please sign in to comment.