Skip to content

test(api): exec session deadlines are checked with the monotonic clock held still - #469

Merged
samuelmbabhazi merged 1 commit into
mainfrom
fix/exec-sessions-test-clock
Nov 25, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
fix/exec-sessions-test-clock

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

exec-sessions.spec.ts fails on CI now and then. It just failed #467's TypeScript job: queues the agent action for the running replica… expected an exact attachBy.

Why

c4c4842 (#456) made ExecSessions.open measure the time its database work takes, on the monotonic clock (performance.now()), so that freshness and deadlines are decided when they are. The test still expected attachBy to be exactly the request time plus 60 s. On a fast machine the work takes under a millisecond, which a Date drops, so the test passed. On a slower runner it takes a millisecond or more, and the deadline moves by that much.

Fix

The opening an exec session tests hold performance still (vi.useFakeTimers({ toFake: ['performance'] })), so deadlines are exact on any machine. The test that checks a slow database already moves the clock itself, and is unchanged. No production code changes.

How it was tested

  • I reproduced CI's failure locally: 5 ms of work inside the fake database, without this change, fail the test with CI's error (expected { …(11) } to match object { …(8) }). With this change, it passes.
  • The file passes five runs in a row, and nx typecheck lint passes for the API.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1295e53 and fb58c66.

Files selected for processing: 1

  • apps/api/src/modules/deployments/application/exec-sessions.spec.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant