Skip to content

Commit aeaa745

Browse files
committed
clearTimeout: ignore invalid timeout ids
1 parent be27359 commit aeaa745

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/html/window.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ pub const Window = struct {
105105
return self.timeoutid;
106106
}
107107

108-
pub fn _clearTimeout(self: *Window, loop: *Loop, id: u32) !void {
109-
if (id >= self.timeoutid) return error.InvalidTimeoutId;
108+
pub fn _clearTimeout(self: *Window, loop: *Loop, id: u32) void {
109+
// I do would prefer return an error in this case, but it seems some JS
110+
// uses invalid id, in particular id 0.
111+
// So we silently ignore invalid id for now.
112+
if (id >= self.timeoutid) return;
113+
110114
loop.cancel(self.timeoutids[id], null);
111115
}
112116
};

0 commit comments

Comments
 (0)