I have the following basic express route in nodejs:
app.get('/timeout', function (req, res) {
setTimeout(() => {
console.log('timeout');
}, 2000);
res.send({ hello: "world" });
});
It doesn't work, it throws an error
TypeError: Cannot read property 'client' of undefined at setTimeout (/Users/myproject/node_modules/@sendgrid/mail/src/classes/mail-service.js:58:10) at /Users/myproject/router.js:87:7
I don't understand why? I have tried not doing a console.log, I tried arrow functions, async await, not sending res.send. What client is meant here?
The other thing that confuses me is that the first line of the error mentions a sendgrid module -which I do have installed, but which I'm not using in this route at all- : at setTimeout (/Users/myproject/node_modules/@sendgrid/mail/src/classes/mail-service.js:58:10)