From b867969e2c1087d877ef7ef9181c69391b9d1f08 Mon Sep 17 00:00:00 2001 From: robobun Date: Sat, 18 Oct 2025 17:04:47 -0700 Subject: [PATCH] Remove unused EventLoopTimer.Arm return type (#23765) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary The `EventLoopTimer.Arm` result from `EventLoopTimer.fire()` was being ignored at both call sites. This PR removes the unused return type and simplifies the code. ## Changes - Changed `EventLoopTimer.fire()` to return `void` instead of `Arm` - Updated all 15 timer callback functions to return `void` - Removed the `Arm` type definition - Simplified the `drainTimers()` loop that was ignoring the return value - Updated both call sites in `Timer.zig` ## Details The `.rearm` functionality was unused - timers that need to reschedule themselves (like DNS resolver) handle this by calling `addTimer()`/`update()` directly rather than relying on the return value. This change removes: - The `Arm` union enum type (3 lines) - All `return .disarm` and `return .{ .rearm = ... }` statements - The switch statement in `drainTimers()` that did nothing with the return value Net result: **-58 lines** of dead code removed. ## Testing - [x] Bun builds successfully with `bun bd` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Bot Co-authored-by: Claude --- src/bake/DevServer.zig | 5 +- src/bake/DevServer/SourceMapStore.zig | 6 +- src/bun.js/api/Timer.zig | 7 +- src/bun.js/api/Timer/EventLoopTimer.zig | 75 +++++++------------ src/bun.js/api/Timer/TimerObjectInternals.zig | 6 +- src/bun.js/api/Timer/WTFTimer.zig | 10 +-- src/bun.js/api/bun/dns.zig | 8 +- src/bun.js/api/bun/subprocess.zig | 7 +- src/bun.js/node/node_fs_stat_watcher.zig | 6 +- src/bun.js/test/bun_test.zig | 4 +- src/deps/uws/UpgradedDuplex.zig | 6 +- src/deps/uws/WindowsNamedPipe.zig | 6 +- src/sql/mysql/js/JSMySQLConnection.zig | 14 ++-- src/sql/postgres/PostgresSQLConnection.zig | 12 ++- src/valkey/js_valkey.zig | 12 +-- 15 files changed, 63 insertions(+), 121 deletions(-) diff --git a/src/bake/DevServer.zig b/src/bake/DevServer.zig index 30ebcdd046..e14cc0564c 100644 --- a/src/bake/DevServer.zig +++ b/src/bake/DevServer.zig @@ -3625,14 +3625,13 @@ pub fn emitVisualizerMessageIfNeeded(dev: *DevServer) void { dev.publish(.incremental_visualizer, payload.items, .binary); } -pub fn emitMemoryVisualizerMessageTimer(timer: *EventLoopTimer, _: *const bun.timespec) EventLoopTimer.Arm { - if (!bun.FeatureFlags.bake_debugging_features) return .disarm; +pub fn emitMemoryVisualizerMessageTimer(timer: *EventLoopTimer, _: *const bun.timespec) void { + if (!bun.FeatureFlags.bake_debugging_features) return; const dev: *DevServer = @alignCast(@fieldParentPtr("memory_visualizer_timer", timer)); assert(dev.magic == .valid); dev.emitMemoryVisualizerMessage(); timer.state = .FIRED; dev.vm.timer.update(timer, &bun.timespec.msFromNow(1000)); - return .disarm; } pub fn emitMemoryVisualizerMessageIfNeeded(dev: *DevServer) void { diff --git a/src/bake/DevServer/SourceMapStore.zig b/src/bake/DevServer/SourceMapStore.zig index 7e6e227226..a2de1f35bc 100644 --- a/src/bake/DevServer/SourceMapStore.zig +++ b/src/bake/DevServer/SourceMapStore.zig @@ -469,7 +469,7 @@ pub fn locateWeakRef(store: *Self, key: Key) ?struct { index: usize, ref: WeakRe return null; } -pub fn sweepWeakRefs(timer: *EventLoopTimer, now_ts: *const bun.timespec) EventLoopTimer.Arm { +pub fn sweepWeakRefs(timer: *EventLoopTimer, now_ts: *const bun.timespec) void { mapLog("sweepWeakRefs", .{}); const store: *Self = @fieldParentPtr("weak_ref_sweep_timer", timer); assert(store.owner().magic == .valid); @@ -489,13 +489,11 @@ pub fn sweepWeakRefs(timer: *EventLoopTimer, now_ts: *const bun.timespec) EventL &store.weak_ref_sweep_timer, &.{ .sec = item.expire + 1, .nsec = 0 }, ); - return .disarm; + return; } } store.weak_ref_sweep_timer.state = .CANCELLED; - - return .disarm; } pub const GetResult = struct { diff --git a/src/bun.js/api/Timer.zig b/src/bun.js/api/Timer.zig index 0e66247057..19afe26222 100644 --- a/src/bun.js/api/Timer.zig +++ b/src/bun.js/api/Timer.zig @@ -240,7 +240,7 @@ pub const All = struct { // Side-effect: potentially call the StopIfNecessary timer. if (min.tag == .WTFTimer) { _ = this.timers.deleteMin(); - _ = min.fire(&now, vm); + min.fire(&now, vm); continue; } @@ -297,10 +297,7 @@ pub const All = struct { var has_set_now: bool = false; while (this.next(&has_set_now, &now)) |t| { - switch (t.fire(&now, vm)) { - .disarm => {}, - .rearm => {}, - } + t.fire(&now, vm); } } diff --git a/src/bun.js/api/Timer/EventLoopTimer.zig b/src/bun.js/api/Timer/EventLoopTimer.zig index c8ed6d911b..10ff1076ea 100644 --- a/src/bun.js/api/Timer/EventLoopTimer.zig +++ b/src/bun.js/api/Timer/EventLoopTimer.zig @@ -100,14 +100,13 @@ pub const Tag = enum { const UnreachableTimer = struct { event_loop_timer: Self, - fn callback(_: *UnreachableTimer, _: *UnreachableTimer) Arm { + fn callback(_: *UnreachableTimer, _: *UnreachableTimer) void { if (Environment.ci_assert) bun.assert(false); - return .disarm; } }; const TimerCallback = struct { - callback: *const fn (*TimerCallback) Arm, + callback: *const fn (*TimerCallback) void, ctx: *anyopaque, event_loop_timer: Self, }; @@ -153,40 +152,32 @@ fn ns(self: *const Self) u64 { return self.next.ns(); } -pub const Arm = union(enum) { - rearm: timespec, - disarm, -}; - -pub fn fire(self: *Self, now: *const timespec, vm: *VirtualMachine) Arm { +pub fn fire(self: *Self, now: *const timespec, vm: *VirtualMachine) void { switch (self.tag) { - .PostgresSQLConnectionTimeout => return @as(*api.Postgres.PostgresSQLConnection, @alignCast(@fieldParentPtr("timer", self))).onConnectionTimeout(), - .PostgresSQLConnectionMaxLifetime => return @as(*api.Postgres.PostgresSQLConnection, @alignCast(@fieldParentPtr("max_lifetime_timer", self))).onMaxLifetimeTimeout(), - .MySQLConnectionTimeout => return @as(*api.MySQL.MySQLConnection, @alignCast(@fieldParentPtr("timer", self))).onConnectionTimeout(), - .MySQLConnectionMaxLifetime => return @as(*api.MySQL.MySQLConnection, @alignCast(@fieldParentPtr("max_lifetime_timer", self))).onMaxLifetimeTimeout(), - .ValkeyConnectionTimeout => return @as(*api.Valkey, @alignCast(@fieldParentPtr("timer", self))).onConnectionTimeout(), - .ValkeyConnectionReconnect => return @as(*api.Valkey, @alignCast(@fieldParentPtr("reconnect_timer", self))).onReconnectTimer(), - .DevServerMemoryVisualizerTick => return bun.bake.DevServer.emitMemoryVisualizerMessageTimer(self, now), - .DevServerSweepSourceMaps => return bun.bake.DevServer.SourceMapStore.sweepWeakRefs(self, now), + .PostgresSQLConnectionTimeout => @as(*api.Postgres.PostgresSQLConnection, @alignCast(@fieldParentPtr("timer", self))).onConnectionTimeout(), + .PostgresSQLConnectionMaxLifetime => @as(*api.Postgres.PostgresSQLConnection, @alignCast(@fieldParentPtr("max_lifetime_timer", self))).onMaxLifetimeTimeout(), + .MySQLConnectionTimeout => @as(*api.MySQL.MySQLConnection, @alignCast(@fieldParentPtr("timer", self))).onConnectionTimeout(), + .MySQLConnectionMaxLifetime => @as(*api.MySQL.MySQLConnection, @alignCast(@fieldParentPtr("max_lifetime_timer", self))).onMaxLifetimeTimeout(), + .ValkeyConnectionTimeout => @as(*api.Valkey, @alignCast(@fieldParentPtr("timer", self))).onConnectionTimeout(), + .ValkeyConnectionReconnect => @as(*api.Valkey, @alignCast(@fieldParentPtr("reconnect_timer", self))).onReconnectTimer(), + .DevServerMemoryVisualizerTick => bun.bake.DevServer.emitMemoryVisualizerMessageTimer(self, now), + .DevServerSweepSourceMaps => bun.bake.DevServer.SourceMapStore.sweepWeakRefs(self, now), .AbortSignalTimeout => { const timeout = @as(*jsc.WebCore.AbortSignal.Timeout, @fieldParentPtr("event_loop_timer", self)); timeout.run(vm); - return .disarm; }, .DateHeaderTimer => { const date_header_timer = @as(*jsc.API.Timer.DateHeaderTimer, @fieldParentPtr("event_loop_timer", self)); date_header_timer.run(vm); - return .disarm; }, .BunTest => { var container_strong = jsc.Jest.bun_test.BunTestPtr.cloneFromRawUnsafe(@fieldParentPtr("timer", self)); defer container_strong.deinit(); - return jsc.Jest.bun_test.BunTest.bunTestTimeoutCallback(container_strong, now, vm); + jsc.Jest.bun_test.BunTest.bunTestTimeoutCallback(container_strong, now, vm); }, .EventLoopDelayMonitor => { const monitor = @as(*jsc.API.Timer.EventLoopDelayMonitor, @fieldParentPtr("event_loop_timer", self)); monitor.onFire(vm, now); - return .disarm; }, inline else => |t| { if (@FieldType(t.Type(), "event_loop_timer") != Self) { @@ -194,34 +185,22 @@ pub fn fire(self: *Self, now: *const timespec, vm: *VirtualMachine) Arm { } var container: *t.Type() = @alignCast(@fieldParentPtr("event_loop_timer", self)); if (comptime t.Type() == TimeoutObject or t.Type() == ImmediateObject) { - return container.internals.fire(now, vm); + container.internals.fire(now, vm); + } else if (comptime t.Type() == WTFTimer) { + container.fire(now, vm); + } else if (comptime t.Type() == StatWatcherScheduler) { + container.timerCallback(); + } else if (comptime t.Type() == uws.UpgradedDuplex) { + container.onTimeout(); + } else if (Environment.isWindows and t.Type() == uws.WindowsNamedPipe) { + container.onTimeout(); + } else if (comptime t.Type() == DNSResolver) { + container.checkTimeouts(now, vm); + } else if (comptime t.Type() == jsc.Subprocess) { + container.timeoutCallback(); + } else { + container.callback(container); } - - if (comptime t.Type() == WTFTimer) { - return container.fire(now, vm); - } - - if (comptime t.Type() == StatWatcherScheduler) { - return container.timerCallback(); - } - if (comptime t.Type() == uws.UpgradedDuplex) { - return container.onTimeout(); - } - if (Environment.isWindows) { - if (comptime t.Type() == uws.WindowsNamedPipe) { - return container.onTimeout(); - } - } - - if (comptime t.Type() == DNSResolver) { - return container.checkTimeouts(now, vm); - } - - if (comptime t.Type() == jsc.Subprocess) { - return container.timeoutCallback(); - } - - return container.callback(container); }, } } diff --git a/src/bun.js/api/Timer/TimerObjectInternals.zig b/src/bun.js/api/Timer/TimerObjectInternals.zig index 5444ed7308..90a765df18 100644 --- a/src/bun.js/api/Timer/TimerObjectInternals.zig +++ b/src/bun.js/api/Timer/TimerObjectInternals.zig @@ -111,7 +111,7 @@ pub fn asyncID(this: *const TimerObjectInternals) u64 { return ID.asyncID(.{ .id = this.id, .kind = this.flags.kind.big() }); } -pub fn fire(this: *TimerObjectInternals, _: *const timespec, vm: *jsc.VirtualMachine) EventLoopTimer.Arm { +pub fn fire(this: *TimerObjectInternals, _: *const timespec, vm: *jsc.VirtualMachine) void { const id = this.id; const kind = this.flags.kind.big(); const async_id: ID = .{ .id = id, .kind = kind }; @@ -146,7 +146,7 @@ pub fn fire(this: *TimerObjectInternals, _: *const timespec, vm: *jsc.VirtualMac this.strong_this.deinit(); this.deref(); - return .disarm; + return; } var time_before_call: timespec = undefined; @@ -228,8 +228,6 @@ pub fn fire(this: *TimerObjectInternals, _: *const timespec, vm: *jsc.VirtualMac } } vm.eventLoop().exit(); - - return .disarm; } fn convertToInterval(this: *TimerObjectInternals, global: *JSGlobalObject, timer: JSValue, repeat: JSValue) void { diff --git a/src/bun.js/api/Timer/WTFTimer.zig b/src/bun.js/api/Timer/WTFTimer.zig index a6ee4184ca..de33c89af8 100644 --- a/src/bun.js/api/Timer/WTFTimer.zig +++ b/src/bun.js/api/Timer/WTFTimer.zig @@ -71,19 +71,11 @@ pub fn cancel(this: *WTFTimer) void { } } -pub fn fire(this: *WTFTimer, _: *const bun.timespec, _: *VirtualMachine) EventLoopTimer.Arm { +pub fn fire(this: *WTFTimer, _: *const bun.timespec, _: *VirtualMachine) void { this.event_loop_timer.state = .FIRED; // Only clear imminent if this timer was the one that set it _ = this.imminent.cmpxchgStrong(this, null, .seq_cst, .seq_cst); - // Read `repeat` and `next` before calling runWithoutRemoving(), because the callback - // might destroy `this` (e.g., when Atomics.waitAsync creates a one-shot DispatchTimer). - const should_repeat = this.repeat; - const next_time = this.event_loop_timer.next; this.runWithoutRemoving(); - return if (should_repeat) - .{ .rearm = next_time } - else - .disarm; } pub fn deinit(this: *WTFTimer) void { diff --git a/src/bun.js/api/bun/dns.zig b/src/bun.js/api/bun/dns.zig index b7ea63ebda..91e0934a4b 100644 --- a/src/bun.js/api/bun/dns.zig +++ b/src/bun.js/api/bun/dns.zig @@ -1987,7 +1987,7 @@ pub const Resolver = struct { const AddrPendingCache = bun.HiveArray(GetHostByAddrInfoRequest.PendingCacheKey, 32); const NameInfoPendingCache = bun.HiveArray(GetNameInfoRequest.PendingCacheKey, 32); - pub fn checkTimeouts(this: *Resolver, now: *const timespec, vm: *jsc.VirtualMachine) EventLoopTimer.Arm { + pub fn checkTimeouts(this: *Resolver, now: *const timespec, vm: *jsc.VirtualMachine) void { defer { vm.timer.incrementTimerRef(-1); this.deref(); @@ -1998,13 +1998,9 @@ pub const Resolver = struct { if (this.getChannelOrError(vm.global)) |channel| { if (this.anyRequestsPending()) { c_ares.ares_process_fd(channel, c_ares.ARES_SOCKET_BAD, c_ares.ARES_SOCKET_BAD); - if (this.addTimer(now)) { - return .{ .rearm = this.event_loop_timer.next }; - } + _ = this.addTimer(now); } } else |_| {} - - return .disarm; } fn anyRequestsPending(this: *Resolver) bool { diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index a7693fa604..c07203e565 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -350,16 +350,15 @@ fn setEventLoopTimerRefd(this: *Subprocess, refd: bool) void { } } -pub fn timeoutCallback(this: *Subprocess) bun.api.Timer.EventLoopTimer.Arm { +pub fn timeoutCallback(this: *Subprocess) void { this.setEventLoopTimerRefd(false); - if (this.event_loop_timer.state == .CANCELLED) return .disarm; + if (this.event_loop_timer.state == .CANCELLED) return; if (this.hasExited()) { this.event_loop_timer.state = .CANCELLED; - return .disarm; + return; } this.event_loop_timer.state = .FIRED; _ = this.tryKill(this.killSignal); - return .disarm; } pub fn onMaxBuffer(this: *Subprocess, kind: MaxBuf.Kind) void { diff --git a/src/bun.js/node/node_fs_stat_watcher.zig b/src/bun.js/node/node_fs_stat_watcher.zig index b75436801d..45d3194290 100644 --- a/src/bun.js/node/node_fs_stat_watcher.zig +++ b/src/bun.js/node/node_fs_stat_watcher.zig @@ -110,19 +110,17 @@ pub const StatWatcherScheduler = struct { this.vm.enqueueTaskConcurrent(jsc.ConcurrentTask.create(jsc.Task.init(&holder.task))); } - pub fn timerCallback(this: *StatWatcherScheduler) EventLoopTimer.Arm { + pub fn timerCallback(this: *StatWatcherScheduler) void { const has_been_cleared = this.event_loop_timer.state == .CANCELLED or this.vm.scriptExecutionStatus() != .running; this.event_loop_timer.state = .FIRED; this.event_loop_timer.heap = .{}; if (has_been_cleared) { - return .disarm; + return; } jsc.WorkPool.schedule(&this.task); - - return .disarm; } pub fn workPoolCallback(task: *jsc.WorkPoolTask) void { diff --git a/src/bun.js/test/bun_test.zig b/src/bun.js/test/bun_test.zig index 838b92a50e..08e8d11cbd 100644 --- a/src/bun.js/test/bun_test.zig +++ b/src/bun.js/test/bun_test.zig @@ -455,7 +455,7 @@ pub const BunTest = struct { return .js_undefined; } - pub fn bunTestTimeoutCallback(this_strong: BunTestPtr, _: *const bun.timespec, vm: *jsc.VirtualMachine) bun.api.Timer.EventLoopTimer.Arm { + pub fn bunTestTimeoutCallback(this_strong: BunTestPtr, _: *const bun.timespec, vm: *jsc.VirtualMachine) void { group.begin(@src()); defer group.end(); const this = this_strong.get(); @@ -472,8 +472,6 @@ pub const BunTest = struct { run(this_strong, vm.global) catch |e| { this.onUncaughtException(vm.global, vm.global.takeException(e), false, .done); }; - - return .disarm; // this won't disable the timer if .run() re-arms it } pub fn runNextTick(weak: BunTestPtr.Weak, globalThis: *jsc.JSGlobalObject, phase: RefDataValue) void { const done_callback_test = bun.new(RunTestsTask, .{ .weak = weak.clone(), .globalThis = globalThis, .phase = phase }); diff --git a/src/deps/uws/UpgradedDuplex.zig b/src/deps/uws/UpgradedDuplex.zig index 4c9f70af3e..26204293e5 100644 --- a/src/deps/uws/UpgradedDuplex.zig +++ b/src/deps/uws/UpgradedDuplex.zig @@ -230,7 +230,7 @@ fn onCloseJS( return .js_undefined; } -pub fn onTimeout(this: *UpgradedDuplex) EventLoopTimer.Arm { +pub fn onTimeout(this: *UpgradedDuplex) void { log("onTimeout", .{}); const has_been_cleared = this.event_loop_timer.state == .CANCELLED or this.vm.scriptExecutionStatus() != .running; @@ -239,12 +239,10 @@ pub fn onTimeout(this: *UpgradedDuplex) EventLoopTimer.Arm { this.event_loop_timer.heap = .{}; if (has_been_cleared) { - return .disarm; + return; } this.handlers.onTimeout(this.handlers.ctx); - - return .disarm; } pub fn from( diff --git a/src/deps/uws/WindowsNamedPipe.zig b/src/deps/uws/WindowsNamedPipe.zig index bf4238e0c4..754dd0add1 100644 --- a/src/deps/uws/WindowsNamedPipe.zig +++ b/src/deps/uws/WindowsNamedPipe.zig @@ -241,7 +241,7 @@ fn onInternalReceiveData(this: *WindowsNamedPipe, data: []const u8) void { } } -pub fn onTimeout(this: *WindowsNamedPipe) EventLoopTimer.Arm { +pub fn onTimeout(this: *WindowsNamedPipe) void { log("onTimeout", .{}); const has_been_cleared = this.event_loop_timer.state == .CANCELLED or this.vm.scriptExecutionStatus() != .running; @@ -250,12 +250,10 @@ pub fn onTimeout(this: *WindowsNamedPipe) EventLoopTimer.Arm { this.event_loop_timer.heap = .{}; if (has_been_cleared) { - return .disarm; + return; } this.handlers.onTimeout(this.handlers.ctx); - - return .disarm; } pub fn from( diff --git a/src/sql/mysql/js/JSMySQLConnection.zig b/src/sql/mysql/js/JSMySQLConnection.zig index 92b31c1b5d..43e6219705 100644 --- a/src/sql/mysql/js/JSMySQLConnection.zig +++ b/src/sql/mysql/js/JSMySQLConnection.zig @@ -106,18 +106,18 @@ pub fn resetConnectionTimeout(this: *@This()) void { this.#vm.timer.insert(&this.timer); } -pub fn onConnectionTimeout(this: *@This()) bun.api.Timer.EventLoopTimer.Arm { +pub fn onConnectionTimeout(this: *@This()) void { this.timer.state = .FIRED; if (this.#connection.isProcessingData()) { - return .disarm; + return; } - if (this.#connection.status == .failed) return .disarm; + if (this.#connection.status == .failed) return; if (this.getTimeoutInterval() == 0) { this.resetConnectionTimeout(); - return .disarm; + return; } switch (this.#connection.status) { @@ -135,14 +135,12 @@ pub fn onConnectionTimeout(this: *@This()) bun.api.Timer.EventLoopTimer.Arm { }, .disconnected, .failed => {}, } - return .disarm; } -pub fn onMaxLifetimeTimeout(this: *@This()) bun.api.Timer.EventLoopTimer.Arm { +pub fn onMaxLifetimeTimeout(this: *@This()) void { this.max_lifetime_timer.state = .FIRED; - if (this.#connection.status == .failed) return .disarm; + if (this.#connection.status == .failed) return; this.failFmt(error.LifetimeTimeout, "Max lifetime timeout reached after {}", .{bun.fmt.fmtDurationOneDecimal(@as(u64, this.max_lifetime_interval_ms) *| std.time.ns_per_ms)}); - return .disarm; } fn setupMaxLifetimeTimerIfNecessary(this: *@This()) void { if (this.max_lifetime_interval_ms == 0) return; diff --git a/src/sql/postgres/PostgresSQLConnection.zig b/src/sql/postgres/PostgresSQLConnection.zig index e176281713..4f4787de42 100644 --- a/src/sql/postgres/PostgresSQLConnection.zig +++ b/src/sql/postgres/PostgresSQLConnection.zig @@ -198,17 +198,17 @@ fn setupMaxLifetimeTimerIfNecessary(this: *PostgresSQLConnection) void { this.vm.timer.insert(&this.max_lifetime_timer); } -pub fn onConnectionTimeout(this: *PostgresSQLConnection) bun.api.Timer.EventLoopTimer.Arm { +pub fn onConnectionTimeout(this: *PostgresSQLConnection) void { debug("onConnectionTimeout", .{}); this.timer.state = .FIRED; if (this.flags.is_processing_data) { - return .disarm; + return; } if (this.getTimeoutInterval() == 0) { this.resetConnectionTimeout(); - return .disarm; + return; } switch (this.status) { @@ -222,15 +222,13 @@ pub fn onConnectionTimeout(this: *PostgresSQLConnection) bun.api.Timer.EventLoop this.failFmt("ERR_POSTGRES_CONNECTION_TIMEOUT", "Connection timeout after {} (sent startup message, but never received response)", .{bun.fmt.fmtDurationOneDecimal(@as(u64, this.connection_timeout_ms) *| std.time.ns_per_ms)}); }, } - return .disarm; } -pub fn onMaxLifetimeTimeout(this: *PostgresSQLConnection) bun.api.Timer.EventLoopTimer.Arm { +pub fn onMaxLifetimeTimeout(this: *PostgresSQLConnection) void { debug("onMaxLifetimeTimeout", .{}); this.max_lifetime_timer.state = .FIRED; - if (this.status == .failed) return .disarm; + if (this.status == .failed) return; this.failFmt("ERR_POSTGRES_LIFETIME_TIMEOUT", "Max lifetime timeout reached after {}", .{bun.fmt.fmtDurationOneDecimal(@as(u64, this.max_lifetime_interval_ms) *| std.time.ns_per_ms)}); - return .disarm; } fn start(this: *PostgresSQLConnection) void { diff --git a/src/valkey/js_valkey.zig b/src/valkey/js_valkey.zig index dd58159e9f..bb24dbc771 100644 --- a/src/valkey/js_valkey.zig +++ b/src/valkey/js_valkey.zig @@ -755,7 +755,7 @@ pub const JSValkeyClient = struct { this.timer.state = .CANCELLED; } - pub fn onConnectionTimeout(this: *JSValkeyClient) Timer.EventLoopTimer.Arm { + pub fn onConnectionTimeout(this: *JSValkeyClient) void { debug("onConnectionTimeout", .{}); // Mark timer as fired @@ -765,12 +765,12 @@ pub const JSValkeyClient = struct { this.ref(); defer this.deref(); if (this.client.flags.failed) { - return .disarm; + return; } if (this.client.getTimeoutInterval() == 0) { this.resetConnectionTimeout(); - return .disarm; + return; } var buf: [128]u8 = undefined; @@ -784,11 +784,9 @@ pub const JSValkeyClient = struct { this.clientFail(msg, protocol.RedisError.ConnectionTimeout) catch {}; // TODO: properly propagate exception upwards }, } - - return .disarm; } - pub fn onReconnectTimer(this: *JSValkeyClient) Timer.EventLoopTimer.Arm { + pub fn onReconnectTimer(this: *JSValkeyClient) void { debug("Reconnect timer fired, attempting to reconnect", .{}); // Mark timer as fired and store important values before doing any derefs @@ -800,8 +798,6 @@ pub const JSValkeyClient = struct { // Execute reconnection logic this.reconnect(); - - return .disarm; } pub fn reconnect(this: *JSValkeyClient) void {