diff options
| author | 2022-09-16 14:28:07 -0700 | |
|---|---|---|
| committer | 2022-09-16 14:28:07 -0700 | |
| commit | da6f954e0dd851af4ad206de74fbcd500d3712e6 (patch) | |
| tree | c397ff4948cf2b482993e63ee3481fa00e8d55bc /src/bun.js | |
| parent | 453eaf6871afdde6f1fe85c0b1e3a44cbd980b10 (diff) | |
| download | bun-da6f954e0dd851af4ad206de74fbcd500d3712e6.tar.gz bun-da6f954e0dd851af4ad206de74fbcd500d3712e6.tar.zst bun-da6f954e0dd851af4ad206de74fbcd500d3712e6.zip | |
Fix process not exiting
Diffstat (limited to '')
| -rw-r--r-- | src/bun.js/event_loop.zig | 8 | ||||
| -rw-r--r-- | src/bun.js/javascript.zig | 10 |
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; } |
