How does node.js continue to work when there are no new events in the queue?

My question is, how does the node.js application, like the http server, work even when there are no new events?

I thought the libuv event loop ends when new events are not queued.

Is this something like a while (true) {} loop with event loggers registered for events?

Here is a simple example code of my question:

var http = require("http");

var server = http.createServer(function(request, response) {
  response.write("Hello World!");
  response.end();
});

server.listen(8080);

thank

EDIT: We know from the libuv io loop document that the loop must be live at the beginning of each iteration of the loop, which means more events, so more callbacks are logged.

In this example, an event listener is registered, but the program exits after processing one event, because no more events were fired before the next iteration of the loop.

var EventEmitter = require('events').EventEmitter;

eventEmitter.on('event1', function() {
  console.log('event1 has occured');
});

eventEmitter.emit('event1');

- .

setTimeout(function() {
  console.log('setTimeout callback occured');
}, 2000);

, ( refd-) http-?

+4
1

HTTP- TCP, uv_tcp_t. ( ), , HTTP-.

, Node uv_timer_t, .

+2

All Articles