mirror of
https://github.com/oven-sh/bun
synced 2026-02-19 23:31:45 +00:00
Remove unused EventLoopTimer.Arm return type (#23765)
## 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 <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user