The callback of the node listener continues to trigger the listener, why it does not cause an infinite loop

const EventEmitter = require("events");

let emitter = new EventEmitter();

let count = 0;
emitter.on("myEvent", () => {
  console.log("hi" + count);
  countPP;
  emitter.emit("myEvent");
});

emitter.emit("myEvent");

my code output

clipboard.png

I just want to ask why it stopped after 1684 trips. Is it caused by node"s own mechanism or something?

Sep.28,2021

this leads to an infinite loop, which is supposed to burst the stack in the end.

Menu