implement events.on (#8190)

* exit event loop if there's unhandled errors

* move FixedQueue to a special package

* require(events) is also EventEmitter

* implement events.on

* move fixed_queue to internal and make it lazy in node:events

* use better Promise intrinsics

* move $shared to internal/shared

* make test not dependent on cwd
This commit is contained in:
Meghan Denny
2024-01-15 18:54:37 -08:00
committed by GitHub
parent a159850cce
commit 6b577a3970
14 changed files with 279 additions and 144 deletions

View File

@@ -655,9 +655,9 @@ pub const VirtualMachine = struct {
}
pub fn isEventLoopAlive(vm: *const VirtualMachine) bool {
return vm.event_loop_handle.?.isActive() or (vm.active_tasks +
vm.event_loop.tasks.count +
vm.event_loop.immediate_tasks.count + vm.event_loop.next_immediate_tasks.count > 0);
return vm.unhandled_error_counter == 0 and
(vm.event_loop_handle.?.isActive() or
vm.active_tasks + vm.event_loop.tasks.count + vm.event_loop.immediate_tasks.count + vm.event_loop.next_immediate_tasks.count > 0);
}
pub fn wakeup(this: *VirtualMachine) void {