aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/event_loop.zig8
-rw-r--r--src/bun.js/javascript.zig10
2 files changed, 7 insertions, 11 deletions
diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig
index a68376872..6a6107b05 100644
--- a/src/bun.js/event_loop.zig
+++ b/src/bun.js/event_loop.zig
@@ -375,8 +375,12 @@ pub const EventLoop = struct {
while (promise.status(this.global.vm()) == .Pending) {
this.tick();
- if (this.virtual_machine.uws_event_loop != null) {
- this.runUSocketsLoop();
+ if (promise.status(this.global.vm()) == .Pending) {
+ if (this.virtual_machine.uws_event_loop != null) {
+ this.runUSocketsLoop();
+ } else if (this.waker) |*waker| {
+ _ = waker.wait() catch 0;
+ }
}
}
},
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index 4f97a79ad..5a085af01 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -1454,15 +1454,7 @@ pub const VirtualMachine = struct {
promise = JSModuleLoader.loadAndEvaluateModule(this.global, &ZigString.init(this.main));
}
- while (promise.status(this.global.vm()) == .Pending) {
- this.eventLoop().tick();
- _ = this.eventLoop().waker.?.wait() catch 0;
- }
-
- if (this.us_loop_reference_count > 0) {
- _ = this.global.vm().runGC(true);
- this.eventLoop().runUSocketsLoop();
- }
+ this.waitForPromise(promise);
return promise;
}