Skip to content

Commit 0094a8d

Browse files
committed
http: add callback is function check
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
1 parent 05d424c commit 0094a8d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/_http_outgoing.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ exports.OutgoingMessage = OutgoingMessage;
8989

9090

9191
OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
92-
if (callback)
92+
93+
if (callback) {
94+
if (typeof callback !== 'function')
95+
throw new TypeError('callback must be a function');
9396
this.on('timeout', callback);
97+
}
9498

9599
if (!this.socket) {
96100
this.once('socket', function(socket) {

0 commit comments

Comments
 (0)