6

So I have this code written in node:

Function connect(){
const client = net.blahblah

client.on('close', () => {
Connect()
}
}

As the connect is called from within the close call back, it wouldn't be recursive right? Like if it disconnected a million times, it shouldn't throw a recursion error or use up a bunch of memory right? Or am I thinking about it wrong?

Comments
  • 2
    Its not called within, you are just setting the callback.
  • 2
    It's not recursion because the call isn't inside the same method as itself but rather in a callback method.
    You will possibly get an "out of memory" or "script execution timeout" exception because there is no limitation on the call insyd *onClose* callback
Add Comment