Skip to content

fix(sqlite-vfs): derive vfs types from Factory#4276

Merged
NathanFlurry merged 1 commit intomainfrom
02-23-fix_sqlite-vfs_derive_vfs_types_from_factory
Feb 24, 2026
Merged

fix(sqlite-vfs): derive vfs types from Factory#4276
NathanFlurry merged 1 commit intomainfrom
02-23-fix_sqlite-vfs_derive_vfs_types_from_factory

Conversation

@NathanFlurry
Copy link
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

@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4276 February 24, 2026 03:59 Destroyed
@railway-app
Copy link

railway-app bot commented Feb 24, 2026

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

Service Status Web Updated (UTC)
website 😴 Sleeping (View Logs) Web Feb 24, 2026 at 4:13 am
mcp-hub ✅ Success (View Logs) Web Feb 24, 2026 at 4:03 am
frontend-inspector ❌ Build Failed (View Logs) Web Feb 24, 2026 at 3:59 am
ladle ❌ Build Failed (View Logs) Web Feb 24, 2026 at 3:59 am
frontend-cloud ❌ Build Failed (View Logs) Web Feb 24, 2026 at 3:59 am

Copy link
Member Author

NathanFlurry commented Feb 24, 2026

@NathanFlurry NathanFlurry marked this pull request as ready for review February 24, 2026 04:00
@NathanFlurry NathanFlurry force-pushed the fix_rivetkit_use_gatewayId_instead_of_requestId_in_connection_persistence_log branch from adb22d7 to fbb6d48 Compare February 24, 2026 04:01
@NathanFlurry NathanFlurry force-pushed the 02-23-fix_sqlite-vfs_derive_vfs_types_from_factory branch from b809ae3 to 55f6824 Compare February 24, 2026 04:01
@claude
Copy link

claude bot commented Feb 24, 2026

PR Review: fix(sqlite-vfs): derive vfs types from Factory

Summary

This PR refactors SqliteSystem to implement SqliteVfsRegistration (derived from the factory API's type signature) instead of extending VFS.Base. This removes implicit inheritance and makes the required interface explicit. It also adds a missing await in Database.exec and defines several previously-inherited VFS callback stubs explicitly.


Positives

  • Type derivation from source of truth: Using type SqliteVfsRegistration = Parameters<SQLite3Api["vfs_register"]>[0] ties the class contract to the actual factory API signature, so TypeScript will catch any interface drift automatically.
  • Explicit VFS method implementations: Adding xLock, xUnlock, xFileControl, and xDeviceCharacteristics directly makes the VFS contract visible rather than relying on inherited no-ops from VFS.Base.
  • exec async fix: The change from implicit return to explicit await in the mutex callback is a correctness improvement. The prior code returned the inner promise without awaiting it, meaning errors thrown inside the callback would not be caught by the outer try/finally in AsyncMutex.run if the promise rejected after the run returned.

Issues

SQLITE_MAX_PATHNAME_BYTES = 64 is well below SQLite's default

SQLite's default SQLITE_MAX_PATHNAME is 512 bytes. Setting this to 64 means xFullPathname will return SQLITE_IOERR for any path >= 64 bytes (the check is bytes.length >= out.length where out.length == nOut == mxPathname). Actor IDs as UUIDs (~36 chars) plus the longest suffix (-journal, 8 chars) = ~44 bytes, which fits — but this is tight and any deviation would silently fail with a generic I/O error.

Suggestion: Use 512 to match the SQLite default, or add an explicit comment documenting why 64 is acceptable given actor-scoped usage:

// Actor file names are UUID-based (~36 bytes) plus SQLite suffixes (-journal, -wal, -shm),
// so 64 bytes is sufficient. Standard SQLite uses 512.
const SQLITE_MAX_PATHNAME_BYTES = 64;

Both mxPathName and mxPathname are set

readonly mxPathName = SQLITE_MAX_PATHNAME_BYTES;
readonly mxPathname = SQLITE_MAX_PATHNAME_BYTES;

Since SqliteVfsRegistration is derived from the actual vfs_register parameter type, the canonical spelling is in that type. It would be worth confirming which one the type actually requires and removing the duplicate, or adding a comment explaining that both spellings exist in different versions of the library.

Empty close() deserves a comment

VFS.Base may have had cleanup logic in close(). The replacement close(): void {} should include a brief comment so it's clear the no-op is intentional:

// No cleanup needed; VFS resources are tied to the actor lifecycle.
close(): void {}

Minor Notes

  • No tests were added or updated to verify the methods newly made explicit (xLock, xUnlock, xFileControl, xDeviceCharacteristics). The existing integration tests in sqlite-vfs-test cover end-to-end behavior, but a note confirming the test suite passes with this change would be useful.
  • The PR description template was not filled out. For a change to a low-level storage layer (removing a base class), a brief test plan would aid reviewers.

Overall this is a good architectural cleanup. The main actionable items are the pathname length constant documentation and the dual-spelling cleanup.

@NathanFlurry NathanFlurry force-pushed the fix_rivetkit_use_gatewayId_instead_of_requestId_in_connection_persistence_log branch from fbb6d48 to 78c338d Compare February 24, 2026 04:13
Base automatically changed from fix_rivetkit_use_gatewayId_instead_of_requestId_in_connection_persistence_log to main February 24, 2026 04:13
@NathanFlurry NathanFlurry force-pushed the 02-23-fix_sqlite-vfs_derive_vfs_types_from_factory branch from 55f6824 to f7de1a2 Compare February 24, 2026 04:14
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4276 February 24, 2026 04:14 Destroyed
@NathanFlurry NathanFlurry merged commit 8eb31d9 into main Feb 24, 2026
4 of 8 checks passed
@NathanFlurry NathanFlurry deleted the 02-23-fix_sqlite-vfs_derive_vfs_types_from_factory branch February 24, 2026 04:14
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