Repository navigation
Conversation
- Schema setup, migration and unsafeResetDatabase() failures on the JSI path reject and reach onSetUpError instead of aborting the app - An unopenable database file, a wrong argument count, and raw SQL the bridge cannot run reject instead of crashing - A failed reset leaves the database open and can be retried, including through database.unsafeResetDatabase() - Adapters clear their cached record IDs before a reset can fail, so JS and adapter caches stay consistent - The JSI prepared statement cache is bounded to 256 statements with LRU eviction Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @joker-777, thank you for this! Crashing at launch instead of reaching I maintain NitromelonDB, a maintained fork of WatermelonDB (New Architecture, Nitro Modules). This one applies there too: our Nitro module still calls Our fork was rewritten in TypeScript (strict mode) to reduce the chance of bugs like this one slipping through, so I think the community would really benefit if you opened your PRs against it too. A couple of notes in case you do:
CI runs the shared adapter suite on real iOS and Android devices, so it would get tested on both platforms. If you don't have the time or would rather not, no worries at all, I'm happy to port it myself. Just let me know. Thanks a lot! |
Fixes the JSI (C++) path of
SQLiteAdapter(jsi: true), so setup and reset failures reject and reachonSetUpErrorinstead of killing the process. Related issue: #1945. This is the JSI counterpart of #1981, which does the same for the legacy (non-JSI) bridges. The two PRs are independent and can be merged in either order.Changes
unsafeResetDatabase()failures reject the promise and reachonSetUpError, instead of callingstd::abort()database.unsafeResetDatabase(). Until a reset succeeds, other calls on it reject instead of failing an assertiondatabase.unsafeResetDatabase()restores the adapter and clears the record caches, so the reset can be retried through the public API. This applies to every adapteridfirstLeft as is: the
std::abort()inconfigureJNI(DatabasePlatformAndroid.cpp) whenGetJavaVMfails. It runs while the JSI binding is installed, before any adapter or promise exists, and a failingGetJavaVMmeans the JNI environment itself is broken.Tests
errors when migration failsnow checks, on JSI, that a database whose migration failed rejects later calls and can then be reset and used againcan retry a failed reset(SQLite) breaks the schema so the reset fails, then retries it on the same adapterrejects raw SQL queries it cannot run (JSI)makeDispatcher/test.js) and forDatabase.unsafeResetDatabase()failingVerification
flow checkis clean, and ESLint is clean on the changed files. Jest passes: 80 suites / 641 tests on the host. Thesqlite-nodesuite (src/adapters/sqlite/test.js) was run separately in a Node 22 container, because better-sqlite3 doesn't build on the host's Node; all 123 tests pass there🤖 Generated with Claude Code