Skip to content

fix(rivetkit): surface native sqlite kv errors to callers#4645

Draft
NathanFlurry wants to merge 1 commit intofix/prevent-sleep-db-racesfrom
fix/surface-native-sqlite-kv-errors
Draft

fix(rivetkit): surface native sqlite kv errors to callers#4645
NathanFlurry wants to merge 1 commit intofix/prevent-sleep-db-racesfrom
fix/surface-native-sqlite-kv-errors

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 13, 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 13, 2026

PR Review: fix(rivetkit): surface native sqlite kv errors to callers

The overall approach is solid - enriching I/O-level errors with KV context while leaving application-level SQLite errors (schema, constraint, etc.) untouched is the right design.

Potential issue: exec error path variable assignment

In the wrapped exec method, result is declared with let before the try block and used after it. TypeScript control flow should handle this since enrichNativeDatabaseError returns never, but under strict mode some TS versions still flag the variable as potentially uninitialized. Worth verifying this compiles cleanly. The run and query wrappers avoid this issue because they do not use a result variable afterward.

Concern: Mutating the caught error object

The code does error.message = ... which mutates the error in-place. Consider creating a new Error with the enriched message and copying error.stack to preserve the original stack trace. Minor concern since these errors are unlikely to be shared, but it is safer practice.

Missing test coverage for exec and query

The two tests only exercise run(). The same enrichment logic is wired into exec() and query(), but there are no tests verifying those paths. Adding at least one test per method would prevent regressions.

Minor: takeLastKvError placement in the interface

The method was inserted between run and close. Consider grouping it at the bottom of the interface as a diagnostic extension for readability.

Minor: Regex coverage

The regex covers i/o error and unable to open database file but SQLite can also emit disk full and SQLITE_IOERR-style messages for I/O failures. A brief comment explaining the intentional narrowness would help future maintainers.

Overall this is a clean, well-scoped diagnostic improvement. Main actionable items: expand test coverage to exec and query, and consider the error mutation pattern.

@NathanFlurry NathanFlurry force-pushed the fix/prevent-sleep-db-races branch from 7825238 to f6957bf Compare April 13, 2026 21:07
@NathanFlurry NathanFlurry force-pushed the fix/surface-native-sqlite-kv-errors branch from c3091c0 to bb11c47 Compare April 13, 2026 21:07
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