mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 06:41:50 +00:00
Add fake timers for bun:test (#23764)
Fixes ENG-21288 TODO: Test with `@testing-library/react` `waitFor` --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -47,10 +47,7 @@ flags: ConnectionFlags = .{},
|
||||
/// After being connected, this is an idle timeout timer.
|
||||
timer: bun.api.Timer.EventLoopTimer = .{
|
||||
.tag = .PostgresSQLConnectionTimeout,
|
||||
.next = .{
|
||||
.sec = 0,
|
||||
.nsec = 0,
|
||||
},
|
||||
.next = .epoch,
|
||||
},
|
||||
|
||||
/// This timer controls the maximum lifetime of a connection.
|
||||
@@ -59,10 +56,7 @@ timer: bun.api.Timer.EventLoopTimer = .{
|
||||
max_lifetime_interval_ms: u32 = 0,
|
||||
max_lifetime_timer: bun.api.Timer.EventLoopTimer = .{
|
||||
.tag = .PostgresSQLConnectionMaxLifetime,
|
||||
.next = .{
|
||||
.sec = 0,
|
||||
.nsec = 0,
|
||||
},
|
||||
.next = .epoch,
|
||||
},
|
||||
auto_flusher: AutoFlusher = .{},
|
||||
|
||||
@@ -135,7 +129,7 @@ pub fn resetConnectionTimeout(this: *PostgresSQLConnection) void {
|
||||
return;
|
||||
}
|
||||
|
||||
this.timer.next = bun.timespec.msFromNow(@intCast(interval));
|
||||
this.timer.next = bun.timespec.msFromNow(.allow_mocked_time, @intCast(interval));
|
||||
this.vm.timer.insert(&this.timer);
|
||||
}
|
||||
|
||||
@@ -194,7 +188,7 @@ fn setupMaxLifetimeTimerIfNecessary(this: *PostgresSQLConnection) void {
|
||||
if (this.max_lifetime_interval_ms == 0) return;
|
||||
if (this.max_lifetime_timer.state == .ACTIVE) return;
|
||||
|
||||
this.max_lifetime_timer.next = bun.timespec.msFromNow(@intCast(this.max_lifetime_interval_ms));
|
||||
this.max_lifetime_timer.next = bun.timespec.msFromNow(.allow_mocked_time, @intCast(this.max_lifetime_interval_ms));
|
||||
this.vm.timer.insert(&this.max_lifetime_timer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user