segmentio/analytics.js-integrations

@segmentio/send-json not being passed a timeout argument

texonidas opened this issue · 3 comments

While running segment locally in debug mode, I've run into an issue in lib/index.js on line 394. The send function being called (@segment/send-json) expects 5 arguments, (url, msg, headers, timeout, fn), however it is only being passed (url, msg, header, fn), and so I am getting constant "i is not a function" errors in my console.

I started seeing the same errors today as well 😅

Issue is right here -

send(url, msg, headers, function(err, res) {
self.debug('sent %O, received %O', msg, [err, res]);
if (fn) {
if (err) return fn(err);
fn(null, res);
}
});

As texonidas mentioned, we are missing a timeout as the fourth argument.

It looks like in this recent commit cf75105#diff-ec90774f0561687711e2f7e544859dfcb2d4900f482bc5eab32fc644159503e1, @segment/send-json was upgraded from v3 to v4.

The json() in v3 expects 4 arguments. The same function in v4 now expects 5 arguments.

#563

I've added pull request to fix this, I just used a 1s for send because I'm really not sure what was an appropriate value to use.