Skip to content

driver-turso: a remote url plus syncUrl is classified replica and handed a :memory: Knex connection, so every write lands in process memory and never reaches the remote #19893

Description

@objectstack-fleet

Filing gate: ① a defect with a named landing site, TursoDriver.detectMode / toKnexConfig in packages/drivers/driver-turso/src/turso-driver.ts. Finding class (a). Derived from #19845's round (PR #19891); ⛔ that PR does not touch it.

Filed by the domain:engine execution seat 1 (session_01TEhopqrWQYBycZzyJHpAZr) from the out-of-scope findings of its #19845 dev (report on #19845). The seat's isolated contract reviewer read the code independently on PR #19891 (record 5797857806, flag ③-2: 「REAL … the most serious of the four; FILE SEPARATELY with priority」). ⛔ Filed bare: routing and grading are triage's. ⛔ Not a claim.

What happens

  • detectMode: a libsql://, https://, http://, wss:// or ws:// url WITH a syncUrl returns replica. A code comment asserts @libsql/client "operates in embedded replica mode with an in-memory local cache".
  • toKnexConfig's last arm hands that mode better-sqlite3 on connection: { filename: ':memory:' }.
  • On a non-remote driver, connect() calls super.connect() (Knex) and builds a libsql client that only sync() uses. Every CRUD and schema call takes the inherited Knex path.

⇒ Writes land in a process-local in-memory SQLite database and vanish when the process exits. sync() moves nothing out of Knex's :memory:, so nothing reaches the remote through the driver's data path, whether or not the client accepts the pair.

Reproduction (the #19845 dev, on the libsql SQLite double)

url: 'libsql://r.turso.io', syncUrl set, client stub, sync.onConnect: false: initObjects plus create, then find returned the row, while the libsql client's database held no tables. The contract reviewer confirmed the path by code reading; it did not re-measure.

Reach

It looks like a supported configuration:

  • TursoDriverConfigSchema (packages/spec, turso.zod.ts) accepts syncUrl beside any url; its only refinement is sync without syncUrl.
  • turso-driver-factory.ts forwards syncUrl from a declared datasource.
  • The driver's own comment claims the pair works.

Not reachable through OS_DATABASE_URL: standalone-stack passes no syncUrl. The README's mode table lists only file: plus syncUrl. A deployment that declares this datasource gets silent data loss that looks normal from outside: reads return what was written, until a restart.

Suggested shape (⛔ not a ruling)

Refuse a remote url beside syncUrl at construction (or classify it remote), with the matching refinement on TursoDriverConfigSchema, loudly, naming the supported replica spelling (url: 'file:…' plus syncUrl). Measure first whether any real deployment or example declares the pair.

Filing-gate answers

Dedupe words: turso replica remote url syncUrl memory · embedded replica knex memory writes lost · turso replica mode libsql url syncUrl


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdomain:enginepriority:p1High: required for production / M2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions