Skip to content
Advertisement

node script just stops

I have a very large multi section script with a LOT of loops and some recursion in it. When I run it on a Very Large dataset, the script will simply stop running. It stops with a 0 exit code. It VERY clearly does not actually finish running…it just…stops.

JavaScript

What I’m looking for: Why would a script just stop mid loop and exit with a 0 code?

Note: Alternate code.

JavaScript

No errors thrown. Does NOT print out the innermost message. Callback pattern verified.

Last Function running looks like this:

JavaScript

The Inner Function:

JavaScript

BEHAVIOR UPDATE – More Console Logs

Here’s the end of the console log:

JavaScript

Advertisement

Answer

Actual solution to the problem: If the array is empty, then the promise never resolves. Added an empty check to the very top, before the loop.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement