Skip to content

test(rivetkit): stabilize actor db driver tests#4664

Open
NathanFlurry wants to merge 1 commit intobreak-up/stabilize-driver-lifecycle-testsfrom
break-up/stabilize-actor-db-tests
Open

test(rivetkit): stabilize actor db driver tests#4664
NathanFlurry wants to merge 1 commit intobreak-up/stabilize-driver-lifecycle-testsfrom
break-up/stabilize-actor-db-tests

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

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 15, 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.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 15, 2026

PR Review: test(rivetkit): stabilize actor db driver tests

Overview

This PR adds retry helpers and sequential execution to actor DB driver tests to reduce flakiness caused by "Actor stopping: database accessed after actor stopped" race conditions.


❌ Critical: Violates the "no retry-loop flake papering" policy

CLAUDE.md explicitly prohibits this approach:

Never paper over flakes with retry loops or bumped waits. When a test flakes, (1) root-cause the race, (2) write a deterministic repro using vi.useFakeTimers() or event-ordered Promise resolution, (3) fix the underlying ordering in core/napi/typescript, (4) delete any flake-workaround note.

Both runWithActorStoppingRetry and expectIntegrityCheckOk are retry loops whose only purpose is to swallow a specific error and try again. This masks a real race — actor.runMixedWorkload or actor.integrityCheck is racing with the actor's stop sequence — rather than fixing it.

The correct resolution is to find the ordering gap in rivetkit-core / rivetkit-napi / rivetkit (TypeScript) that allows the DB to be accessed after the actor has stopped, and fix it there so the test never sees this error in the first place.


✅ Good: describe.sequential

Switching to describe.sequential is a legitimate stabilization. If tests within the block shared an actor instance (same key) or relied on ordering, parallel execution would cause interference. This is an appropriate Vitest configuration change.


⚠️ Design issue: duplicated retry logic

runWithActorStoppingRetry and expectIntegrityCheckOk share identical structure — only the inner call and the retry count differ. The latter wraps an assertion, the former wraps a void operation. If the retry pattern is kept (pending fixing the root cause), these should be unified into a single generic helper:

async function withActorStoppingRetry<T>(
    driverTestConfig: DriverTestConfig,
    maxAttempts: number,
    fn: () => Promise<T>,
): Promise<T> { ... }

⚠️ Unnecessary double async/await wrapping at call sites

The call sites use async () => await actor.integrityCheck() where () => actor.integrityCheck() suffices — the outer async/await wrapper is redundant since the result is already a Promise<string>.


⚠️ Retry count asymmetry without explanation

runWithActorStoppingRetry uses 3 attempts; expectIntegrityCheckOk uses 6. The reason for the difference is not documented. If there is a principled reason (e.g., the integrity check races a longer recovery window), add a comment. If not, pick one value.


Summary

Change Assessment
describe.sequential ✅ Appropriate fix
runWithActorStoppingRetry retry helper ❌ Violates project policy — masks race, does not fix it
expectIntegrityCheckOk retry helper ❌ Violates project policy — masks race, does not fix it
Duplicate retry structure ⚠️ Should be a single generic helper if kept

The describe.sequential change should land. The retry helpers should be replaced with a root-cause fix in core/napi/typescript that eliminates the "database accessed after actor stopped" race from the test path entirely.

@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-actor-db-tests branch from 9c1861c to 8a0be32 Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-driver-lifecycle-tests branch from 1d9c571 to 8e50d57 Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry changed the base branch from break-up/stabilize-driver-lifecycle-tests to graphite-base/4664 April 15, 2026 03:07
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-actor-db-tests branch from 8a0be32 to f676d13 Compare April 15, 2026 06:55
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4664 to break-up/stabilize-driver-lifecycle-tests April 15, 2026 06:55
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-driver-lifecycle-tests branch from 5aeb5f4 to 4d25019 Compare April 27, 2026 05:57
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-actor-db-tests branch from f676d13 to 49811bf Compare April 27, 2026 05:57
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-driver-lifecycle-tests branch from 4d25019 to d893b81 Compare April 27, 2026 07:30
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-actor-db-tests branch from 49811bf to 1d1e875 Compare April 27, 2026 07:31
@NathanFlurry NathanFlurry marked this pull request as ready for review April 27, 2026 07:40
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