Skip to content

[slop]fix(rivetkit): remove async drizzle db proxy#4984

Open
abcxff wants to merge 1 commit into05-05-fix_rivetkit_use_keepawake_for_websocket_callback_tracking_to_prevent_c.vars_crash_after_grace_deadlinefrom
05-06-_slop_fix_rivetkit_remove_async_drizzle_db_proxy
Open

[slop]fix(rivetkit): remove async drizzle db proxy#4984
abcxff wants to merge 1 commit into05-05-fix_rivetkit_use_keepawake_for_websocket_callback_tracking_to_prevent_c.vars_crash_after_grace_deadlinefrom
05-06-_slop_fix_rivetkit_remove_async_drizzle_db_proxy

Conversation

@abcxff
Copy link
Copy Markdown
Contributor

@abcxff abcxff commented May 6, 2026

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

@railway-app
Copy link
Copy Markdown

railway-app Bot commented May 6, 2026

🚅 Deployed to the rivet-pr-4984 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-inspector ❌ Build Failed (View Logs) Web May 6, 2026 at 10:02 pm
frontend-cloud ❌ Build Failed (View Logs) Web May 6, 2026 at 10:01 pm
kitchen-sink ❌ Build Failed (View Logs) Web May 6, 2026 at 10:00 pm
website 😴 Sleeping (View Logs) Web May 6, 2026 at 4:30 am
ladle ❌ Build Failed (View Logs) Web May 6, 2026 at 4:19 am
mcp-hub ✅ Success (View Logs) Web May 6, 2026 at 4:18 am

Copy link
Copy Markdown
Contributor Author

abcxff commented May 6, 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
Contributor

claude Bot commented May 6, 2026

Code Review

Overview

This PR removes the async Proxy-based wrapper on the db getter in ActorContextHandleAdapter and replaces it with a direct synchronous lookup of the pre-warmed database client from runtime state. If the client hasn't been initialized yet (i.e., before the migration lifecycle callback runs), it now throws an explicit error rather than lazily initializing.

This aligns well with the Fail-By-Default Runtime principle in CLAUDE.md: avoid silent no-ops and throw explicit errors with actionable context instead of returning early.


Positive Changes

  • Removes fragile async Proxy pattern. The old Proxy had to special-case property === "then" to avoid accidentally being treated as a thenable — a subtle footgun. The new synchronous getter is cleaner and behaves like users expect.
  • Synchronous db access. Drizzle and similar ORMs return synchronous client objects; the async wrapper was unnecessary indirection.
  • Explicit lifecycle error. The new databaseClientNotReadyError surfaces clearly if the lifecycle contract is violated, rather than silently constructing a fresh client mid-handler.
  • Cleanup of #dbProxy field. Removes dead state; the #db cache is now the single source of truth for the initialized client.

Concerns / Suggestions

1. ensureDatabaseClient duplicates the new db getter logic

The first ~10 lines of ensureDatabaseClient (lines ~2639-2654) are now identical to the db getter (check this.#db, check runtimeState.databaseClient, cache and return). This is minor, but consider adding a comment noting that db (user-facing) is the synchronous fast-path and ensureDatabaseClient is the async initialization path that also handles creation.

2. No tests

The PR checklist is entirely unchecked. This change alters a behavioral contract — the db getter now throws instead of lazily initializing. Consider adding tests that:

  • Verify db access inside an action handler works (happy path).
  • Verify db access before prepare()/migration throws actor.database_client_not_ready.

3. Error message wording

"file an issue if you can reproduce"

Informally worded. Consider linking to the repo: "file an issue at https://github.com/rivet-dev/rivet/issues if you can reproduce". Minor nit.

4. Lifecycle documentation

The error message says "the migration callback should have pre-warmed the client" but prepare() also pre-warms the client without a migration. The onMigrate wrapper fires when config.onMigrate is a function or databaseProvider !== undefined, so this should always be covered. Worth confirming there's no path where a DB provider is configured but neither prepare() nor onMigrate runs before the first user action.


Minor Style Notes

  • Error function name databaseClientNotReadyError follows the existing convention (databaseNotConfiguredError, stateNotEnabledError). ✓
  • Lowercase error message text matches CLAUDE.md conventions. ✓
  • { public: true } on the internal error is correct — users should receive this even though they can't fix it themselves. ✓

Summary

Clean simplification that reduces complexity and makes lifecycle violations explicit rather than silently patching around them. Main gaps are the missing tests and the light duplication between the db getter and ensureDatabaseClient. Once those are addressed this looks good to merge.

@abcxff abcxff changed the base branch from 05-06-fix_rivetkit-napi_demote_bridge_error_decode_log_from_warn_to_debug to graphite-base/4984 May 6, 2026 21:59
@abcxff abcxff force-pushed the graphite-base/4984 branch from 2bdaa73 to 0499832 Compare May 6, 2026 21:59
@abcxff abcxff force-pushed the 05-06-_slop_fix_rivetkit_remove_async_drizzle_db_proxy branch from 1134c24 to abb6ff1 Compare May 6, 2026 21:59
@abcxff abcxff changed the base branch from graphite-base/4984 to 05-05-fix_rivetkit_use_keepawake_for_websocket_callback_tracking_to_prevent_c.vars_crash_after_grace_deadline May 6, 2026 21:59
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