diff options
Diffstat (limited to 'src/bun.js/event_loop.zig')
-rw-r--r-- | src/bun.js/event_loop.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 7fe248dad..0e2d16486 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -521,7 +521,18 @@ pub const EventLoop = struct { } // TODO: fix this technical debt - pub fn waitForPromise(this: *EventLoop, promise: *JSC.JSInternalPromise) void { + pub fn waitForPromise(this: *EventLoop, promise: anytype) void { + return waitForPromiseWithType(this, std.meta.Child(@TypeOf(promise)), promise); + } + + pub fn waitForPromiseWithType(this: *EventLoop, comptime Promise: type, promise: *Promise) void { + comptime { + switch (Promise) { + JSC.JSPromise, JSC.JSInternalPromise => {}, + else => @compileError("Promise must be a JSPromise or JSInternalPromise, received: " ++ @typeName(Promise)), + } + } + switch (promise.status(this.global.vm())) { JSC.JSPromise.Status.Pending => { while (promise.status(this.global.vm()) == .Pending) { |