diff --git a/src/html/window.zig b/src/html/window.zig index 0747c709..cef16e94 100644 --- a/src/html/window.zig +++ b/src/html/window.zig @@ -128,7 +128,7 @@ pub const Window = struct { if (self.timeoutid >= self.timeoutids.len) return error.TooMuchTimeout; const ddelay: u63 = delay orelse 0; - const id = loop.timeout(ddelay * std.time.ns_per_ms, cbk); + const id = try loop.timeout(ddelay * std.time.ns_per_ms, cbk); self.timeoutids[self.timeoutid] = id; defer self.timeoutid += 1; @@ -136,12 +136,12 @@ pub const Window = struct { return self.timeoutid; } - pub fn _clearTimeout(self: *Window, loop: *Loop, id: u32) void { + pub fn _clearTimeout(self: *Window, loop: *Loop, id: u32) !void { // I do would prefer return an error in this case, but it seems some JS // uses invalid id, in particular id 0. // So we silently ignore invalid id for now. if (id >= self.timeoutid) return; - loop.cancel(self.timeoutids[id], null); + try loop.cancel(self.timeoutids[id], null); } }; diff --git a/src/http/client.zig b/src/http/client.zig index 4669a3e0..ff1bfe9d 100644 --- a/src/http/client.zig +++ b/src/http/client.zig @@ -282,7 +282,7 @@ pub const Request = struct { }; } - loop.connect(AsyncHandlerT, async_handler, &async_handler.read_completion, AsyncHandlerT.connected, socket, address); + try loop.connect(AsyncHandlerT, async_handler, &async_handler.read_completion, AsyncHandlerT.connected, socket, address); } // Does additional setup of the request for the firsts (i.e. non-redirect) call. @@ -490,7 +490,6 @@ fn AsyncHandler(comptime H: type, comptime L: type) type { } fn connected(self: *Self, _: *IO.Completion, result: IO.ConnectError!void) void { - self.loop.onConnect(result); result catch |err| return self.handleError("Connection failed", err); self.connection.connected() catch |err| { self.handleError("connected handler error", err); @@ -518,11 +517,12 @@ fn AsyncHandler(comptime H: type, comptime L: type) type { sent, self.socket, node.data, - ); + ) catch |err| { + self.handleError("loop send error", err); + }; } fn sent(self: *Self, _: *IO.Completion, n_: IO.SendError!usize) void { - self.loop.onSend(n_); const n = n_ catch |err| { return self.handleError("Write error", err); }; @@ -548,7 +548,9 @@ fn AsyncHandler(comptime H: type, comptime L: type) type { sent, self.socket, next_.data, - ); + ) catch |err| { + self.handleError("loop send error", err); + }; return; } @@ -567,18 +569,19 @@ fn AsyncHandler(comptime H: type, comptime L: type) type { } self.is_receiving = true; - return self.loop.recv( + self.loop.recv( Self, self, &self.read_completion, Self.received, self.socket, self.read_buf[self.read_pos..], - ); + ) catch |err| { + self.handleError("loop recv error", err); + }; } fn received(self: *Self, _: *IO.Completion, n_: IO.RecvError!usize) void { - self.loop.onRecv(n_); self.is_receiving = false; const n = n_ catch |err| { return self.handleError("Read error", err); diff --git a/vendor/zig-js-runtime b/vendor/zig-js-runtime index 8fd91765..ecc49dc1 160000 --- a/vendor/zig-js-runtime +++ b/vendor/zig-js-runtime @@ -1 +1 @@ -Subproject commit 8fd9176583b90f5a5dda0c8e3310525ccc14427c +Subproject commit ecc49dc13a74c046904e1eef8823226c1159cc71