.js function stops (loop)

It’s a backend function but I can’t see any errors anywhere.