Unhandled error in scheduled steps causes app to crash (NodeJS)

Currently, Wappler’s NodeJS script doesn’t give enough traceback when an error occurs within a scheduled workflow. Example given:

2022-02-02T03:00:19.050161349Z App listening at http://localhost:80
2022-02-02T04:00:10.320018604Z node:internal/process/promises:246
2022-02-02T04:00:10.320079980Z           triggerUncaughtException(err, true /* fromPromise */);
2022-02-02T04:00:10.320088256Z           ^
2022-02-02T04:00:10.320094488Z 
2022-02-02T04:00:10.320101241Z Error: connect ECONNREFUSED x.x.x.x:3011
2022-02-02T04:00:10.320107693Z     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
2022-02-02T04:00:10.320114195Z Emitted 'error' event on Job instance at:
2022-02-02T04:00:10.320120748Z     at /usr/src/app/node_modules/node-schedule/lib/Invocation.js:277:17
2022-02-02T04:00:10.320127169Z     at processTicksAndRejections (node:internal/process/task_queues:96:5) {
2022-02-02T04:00:10.320133532Z   errno: -111,
2022-02-02T04:00:10.320139613Z   code: 'ECONNREFUSED',
2022-02-02T04:00:10.320145776Z   syscall: 'connect',
2022-02-02T04:00:10.320151756Z   address: 'x.x.x.x',
2022-02-02T04:00:10.320162777Z   port: 3011
2022-02-02T04:00:10.320174639Z }

The problem with this, I’m unable to see precisely at which step the error occurs. Through these lines I can see the error occurs when called through the task scheduler (cron):

2022-02-02T04:00:10.320114195Z Emitted 'error' event on Job instance at:
2022-02-02T04:00:10.320120748Z     at /usr/src/app/node_modules/node-schedule/lib/Invocation.js:277:17
2022-02-02T04:00:10.320127169Z     at processTicksAndRejections (node:internal/process/task_queues:96:5) {

But what step exactly? I don’t even know which schedule this error occurs! (fortunately, this is a small app, so I found the problem)

To replicate, just create an API Action calling a random IP address, and then set the built-in scheduler (cron) to execute such Server Action. There’s simply not enough information to aid diagnostics.

It also crashes the server, so this is a bug report

What kind of action steps do you have in the scheduled job? Seems like an error while trying to connect to port 3011, not sure what it is trying to connect to. I can prevent the server from crashing, but that doesn’t prevent the error from happening.

It’s fetching data from a micro-service (through API Action step). In this case, the micro-service was indeed offline. While the issue is solved by now, I suggest to enhance the traceback to point out at which schedule the error occurred, because it may not be so obvious next time

Also planning to integrate Sentry, so it if plays nice with that that’s a bonus! (to capture failed schedules)

I’ve added extra error handling that should prevent the server from crashing. We are investigating on how we can do some logging so that you can see when something goes wrong.

1 Like

Fixed in Wappler 4.5.2

This topic was automatically closed after 46 hours. New replies are no longer allowed.