Skip to content

Commit

Permalink
http: add callback is function check
Browse files Browse the repository at this point in the history
We were checking that the callback existed, but not
checking that it was a function. In `setTimeout`, if
callback is truthy but not a function, throw a
TypeError

Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
PR-URL: #3090
  • Loading branch information
jasnell committed Oct 6, 2015
1 parent 05d424c commit 0094a8d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ exports.OutgoingMessage = OutgoingMessage;


OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
if (callback)

if (callback) {
if (typeof callback !== 'function')
throw new TypeError('callback must be a function');
this.on('timeout', callback);
}

if (!this.socket) {
this.once('socket', function(socket) {
Expand Down

0 comments on commit 0094a8d

Please sign in to comment.