mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 22:01:47 +00:00
Fix setTimeout(() => {}, 0) and align setImmediate behavior with Node.js (#6674)
* Fix setTimeout(() => {}, 0)
* Align `setImmediate` with Node.js
* Update event_loop.zig
* Update test
* use Bun.sleep
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -976,8 +976,10 @@ pub const TestCommand = struct {
|
||||
vm.eventLoop().tick();
|
||||
|
||||
var prev_unhandled_count = vm.unhandled_error_counter;
|
||||
while (vm.active_tasks > 0) {
|
||||
if (!jest.Jest.runner.?.has_pending_tests) jest.Jest.runner.?.drain();
|
||||
while (vm.active_tasks > 0) : (vm.eventLoop().flushImmediateQueue()) {
|
||||
if (!jest.Jest.runner.?.has_pending_tests) {
|
||||
jest.Jest.runner.?.drain();
|
||||
}
|
||||
vm.eventLoop().tick();
|
||||
|
||||
while (jest.Jest.runner.?.has_pending_tests) {
|
||||
@@ -991,6 +993,9 @@ pub const TestCommand = struct {
|
||||
prev_unhandled_count = vm.unhandled_error_counter;
|
||||
}
|
||||
}
|
||||
|
||||
vm.eventLoop().flushImmediateQueue();
|
||||
|
||||
switch (vm.aggressive_garbage_collection) {
|
||||
.none => {},
|
||||
.mild => {
|
||||
|
||||
Reference in New Issue
Block a user