I am trying to run a cron job on Heroku which runs daily. The node version this Heroku server/project uses is v9.4. I am also using the async package v2.6.1
When I run the file using node: node dist/filename.js
It gives an error and doesn't run the file anymore:
superagent: Enable experimental feature http2
(node:8233) ExperimentalWarning: The http2 module is an experimental API.
Connected to mongo database
{ Error: certificate has expired
at TLSSocket.onConnectSecure (_tls_wrap.js:1046:34)
at TLSSocket.emit (events.js:180:13)
at TLSSocket._finishInit (_tls_wrap.js:633:8) code: 'CERT_HAS_EXPIRED', response: undefined }
(node:8233) UnhandledPromiseRejectionWarning: Error: certificate has expired
at TLSSocket.onConnectSecure (_tls_wrap.js:1046:34)
at TLSSocket.emit (events.js:180:13)
at TLSSocket._finishInit (_tls_wrap.js:633:8)
(node:8233) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8233) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I've went ahead and tried adding a try catch block inside of the async block, but it still throws the same error.
import async from "async";
.
.
.
function iterateAndGenStats(userData) {
async.eachSeries(userData, (user, cb) => {
try {
.
.
.
cb();
} catch (err) {
console.log(err);
}
},
() => {
cronSlackService.CronSuccessUpdate(
`statistics for applications have been generated. Details are provided below ...`,
);
}
);
}
If I were to use node v12 and run the same command, it works just fine with no errors. It only happens when I switch to node v9 where this error occurs. The only idea that comes to mind is to upgrade the node version of my server project to avoid this error.