Skip to content

test(rivetkit): relax sqlite sleep fixture timing#4738

Closed
NathanFlurry wants to merge 1 commit into04-24-fix_rivetkit_sleep_wake_client_recoveryfrom
04-24-test_rivetkit_sleep_fixture_timing
Closed

test(rivetkit): relax sqlite sleep fixture timing#4738
NathanFlurry wants to merge 1 commit into04-24-fix_rivetkit_sleep_wake_client_recoveryfrom
04-24-test_rivetkit_sleep_fixture_timing

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

This was referenced Apr 24, 2026
Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 24, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@NathanFlurry NathanFlurry force-pushed the 04-24-test_rivetkit_sleep_fixture_timing branch from 269e08e to 66c5481 Compare April 24, 2026 08:45
@claude
Copy link
Copy Markdown

claude Bot commented Apr 24, 2026

PR Review: test(rivetkit): relax sqlite sleep fixture timing

Summary: This PR makes two changes: (1) bumps sleepTimeout from 100 ms to 1,000 ms and adds an explicit sleepGracePeriod: 50 ms in two SQLite fixture actors (actor-db-raw.ts and db-pragma-migration.ts), and (2) adds @rivetkit/sql-loader@2.2.1 as a resolved dependency in pnpm-lock.yaml for the examples/kitchen-sink importer.


Code Quality and Correctness

sleepGracePeriod and sleepTimeout split is well-motivated.

The original sleepTimeout: 100 was extremely tight. A single idle-check tick plus any system jitter on a loaded CI runner could easily exceed it before the actor fully settled. The new split (sleepTimeout: 1_000, sleepGracePeriod: 50) is the correct pattern: the idle window is wide enough to be robust, while the grace period stays short so tests do not hang waiting for teardown.

Inconsistency with db-stress.ts and state-zod-coercion.ts.

Two other fixture actors still use the old sleepTimeout: 100 without a sleepGracePeriod:

  • rivetkit-typescript/packages/rivetkit/fixtures/driver-test-suite/db-stress.ts
  • rivetkit-typescript/packages/rivetkit/fixtures/driver-test-suite/state-zod-coercion.ts

If timing fragility from a 100 ms sleepTimeout was the root cause, those actors are equally fragile, especially db-stress.ts which issues concurrent DB operations that can extend action processing time. Consider aligning those fixtures in the same pass.

The SLEEP_WAIT_MS = 150 in actor-db-pragma-migration.test.ts now covers the new fixture sleepGracePeriod = 50 ms with sufficient margin, since triggerSleep() bypasses the idle timer. This is fine.


pnpm-lock.yaml change: @rivetkit/sql-loader@2.2.1

The resolved version (2.2.1) does not match the workspace version (2.3.0-rc.4).

The local workspace package at rivetkit-typescript/packages/sql-loader/package.json has version 2.3.0-rc.4. The examples/kitchen-sink/package.json lists "@rivetkit/sql-loader": "*", which per CLAUDE.md convention for examples should resolve to the local workspace via the root resolutions block. However, @rivetkit/sql-loader is NOT listed in the root package.json resolutions block, so * resolves to the latest published npm version (2.2.1) instead of the local workspace package.

This means the kitchen-sink example is running against a stale published version of sql-loader rather than the locally modified one. Per CLAUDE.md: "Add new internal @rivetkit/* packages to root resolutions with workspace:* if missing."

Recommended fix: Add "@rivetkit/sql-loader": "workspace:*" to both resolutions and pnpm.overrides in /package.json, then run pnpm install so the lockfile resolves to the local link instead of the npm snapshot.


Potential Flake Risk

actor-db-raw.test.ts "maintains separate databases for different actors" test.

This test uses vi.waitFor with a 10 s timeout and 100 ms poll interval. During each poll, getActor1().getCount() and getActor2().getCount() are called. These are actions that reset the sleep deadline. With the new sleepTimeout: 1_000, the sleep deadline reset window is 10x wider. This is an existing pattern and within acceptable bounds given the 10 s DB_READY_TIMEOUT_MS margin, but worth flagging as a pre-existing structural concern.


Minor Issues

Duplicate SLEEP_GRACE_PERIOD_MS constant. The constant const SLEEP_GRACE_PERIOD_MS = 50 is defined identically in both actor-db-raw.ts and db-pragma-migration.ts. If more fixtures adopt this pattern, consider exporting it from a shared fixture constants file.

check:wait-for-comments compliance: Both vi.waitFor calls have adjacent justification comments. Compliant.


Summary

Area Finding Severity
pnpm-lock.yaml sql-loader resolves to npm 2.2.1 instead of local workspace Missing root resolutions entry for @rivetkit/sql-loader Medium
db-stress.ts and state-zod-coercion.ts still use sleepTimeout: 100 Incomplete fix; same fragility left in other fixtures Low
SLEEP_GRACE_PERIOD_MS = 50 duplicated across two files Minor duplication Low
Sleep/action polling safety in sleep-wait tests Within acceptable bounds given 10 s timeout Pass
check:wait-for-comments compliance Both vi.waitFor calls have adjacent justification comments Pass

The core fixture timing fix is correct and improves test reliability. The main issue to address before merging is the pnpm-lock.yaml change that pulls in a published npm version of sql-loader (2.2.1) instead of the local workspace package (2.3.0-rc.4).

@github-actions
Copy link
Copy Markdown
Contributor

Preview packages published to npm

Install with:

npm install rivetkit@pr-4738

All packages published as 0.0.0-pr.4738.bcfa930 with tag pr-4738.

Engine binary is shipped via @rivetkit/engine-cli on linux-x64-musl, linux-arm64-musl, darwin-x64, and darwin-arm64. Windows users should use the release installer or set RIVET_ENGINE_BINARY.

Docker images:

docker pull rivetdev/engine:slim-bcfa930
docker pull rivetdev/engine:full-bcfa930
Individual packages
npm install rivetkit@pr-4738
npm install @rivetkit/react@pr-4738
npm install @rivetkit/rivetkit-napi@pr-4738
npm install @rivetkit/workflow-engine@pr-4738

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