Database had five public ways to open a connection: connect,
connect_with_encryption, connect_with_page_codec, connect_async and
connect_with_encryption_async. Every new connection setting needs more
variants, and the async path doubles them again.
Database::connect and Database::connect_async now take a ConnectOpts
that holds the encryption key and the page codec, and the other three
variants are removed. ConnectOpts has no Default, so every caller goes
through ConnectOpts::new() and a required argument added there later
makes the compiler find every call site.
`cargo doc --workspace --no-deps` reported many rustdoc warnings. Fix
them without changing what any comment says:
- Wrap bare URLs in `<` and `>` so rustdoc renders them as links.
- Drop explicit link targets that only repeat the link text.
- Point intra-doc links at the item's real path, or write names that
rustdoc cannot resolve as plain code text.
- Escape `<` and `>` that are not HTML tags.
- Add the braces rustdoc needs to parse the example code blocks.
Tests: cargo doc --workspace --no-deps reports no rustdoc warnings
Co-authored-by: Pekka Enberg <penberg@iki.fi>
bootstrap_db and open_db log the sync options with {:?}, and the derived
Debug printed the base64 remote encryption key into the sync logs.
Add a Secret wrapper in the sync engine whose Debug output is always
"<redacted>" and whose value is only reachable through expose(). The
options, the sync operation context and the lazy storage all keep the key
as a Secret, so any struct that holds it can keep deriving Debug without
leaking it. The only expose() call is where the HTTP request header is
built.
Tests: opts_debug_output_hides_the_remote_encryption_key in sync/engine
The native concurrent-updates test started pull and push loops that
rescheduled themselves forever. They kept running through the remaining
tests in the file, and after the test server shut down they logged
"fetch failed" errors in a tight loop. When Vitest shut down the worker
while one of those log calls was still pending, it reported
EnvironmentTeardownError as an unhandled error and failed the job even
though every test passed.
Stop both loops at the end of the test, wait for them to finish, and
close the database.
Update vitest from 3.2.7 to 4.1.11 to pick up the fix for the
@vitest/mocker advisory: before 4.1.11, a client that can reach the dev
server can register a redirect mock pointing at any file and read that
file's contents. 4.1.11 checks the target against the dev server's
allowed files.
Vitest 4 moved Playwright browser support into a separate package, so
the wasm packages (`packages/wasm`, `sync/packages/wasm`) now depend on
`@vitest/browser-playwright` instead of `@vitest/browser`, and their
`vitest.config.ts` passes `provider: playwright()`.
Note: vitest 4 resolves its own vite 8.3.0, while our packages still use
vite ^7.3.5 for `vite build`, so both are installed.
Tests: `packages/common` tests pass on vitest 4.1.11. Native and browser
tests are left to CI.
Closes#9097
AggStep only had fast paths for integer sum and min/max, so sum() and
total() over floats, every avg() and every count() went through the generic
step. That step matches on the function again, re-reads every payload slot
and writes all of them back for each row. TPC-H Q1 runs seven of its eight
aggregates over 6M rows on that path.
The new fast paths cover a float or an integer below 2^52 added to a float
sum or avg total, and count. Integers below 2^52 convert to a float exactly,
like the non-split branch of SQLite's kahanBabuskaNeumaierStepInt64. Each
fast path produces the same payload as the generic step, which still handles
the first row, non-numeric values, larger integers, integer overflow and
totals that are no longer finite.
Tests: agg-functions/sum-large-float.sqltest covers the rounding error term,
float input after an integer overflow, integers on both sides of 2^52 after
floats in sum and avg, total() over integers, an infinite total and count
over mixed value types.
Vitest before 4.1.11 ships a @vitest/mocker that lets a client register a
redirect mock pointing at any file, and then read that file through the dev
server. Version 4.1.11 checks the target against the dev server's allowed
files.
Vitest 4 moved Playwright browser support into @vitest/browser-playwright, so
the wasm packages now depend on it and pass playwright() as the provider.
The message for LimboError::ReadOnly was "Error: Resource is read-only".
SQLite says "attempt to write a readonly database", which is what the
upstream tests and the JavaScript binding tests compare against.
`checkpoint()` on a partial-sync database failed deterministically
whenever the WAL was empty:
- a checkpoint with frames in the WAL succeeds, and its final `TRUNCATE`
truncates `-wal` to 0 bytes (`truncate_log`, `core/storage/wal.rs`)
- every subsequent checkpoint while the WAL is empty fails with `I/O
error (pread): unexpected end of file`
`checkpoint()` → `checkpoint_passive()` begins by reading the WAL salt,
and `read_wal_salt`
(`sync/engine/src/database_sync_operations.rs`) is written for a WAL
file that may be shorter than one
32-byte header: its completion callback zero-fills on a short read and
returns "no salt". The file still
exists after a truncating checkpoint, so `try_open` returns it and the
header read runs against 0 bytes.
Partial sync is the only mode that swaps the IO backend —
`persistent_io(partial)` hands out
`SparseLinuxIo` instead of `PlatformIO` (`sync/sdk-kit/src/rsapi.rs`,
same in `bindings/javascript/sync/src/lib.rs`)
— and `SparseLinuxFile::pread` used `read_exact_at`, which returns
`UnexpectedEof` where a short read was
expected. On Linux `libc::pread` never produces `UnexpectedEof`, so the
reported error string could only
come from this one call site.
The fix makes `SparseLinuxFile::pread` report the number of bytes read
and stop at end of file, matching
`UnixFile::pread` in `core/io/unix.rs`. Both callers already handle a
short read: `read_wal_salt` treats it
as "no salt", and core's page reads treat a zero-length read as an
absent page.
Two clarifications on the original report:
- Full-sync replicas were never affected, because they use `PlatformIO`.
- The failure does not depend on unmaterialized pages. The engine-level
test bootstraps a prefix covering
the whole database — zero holes — and still reproduced it, since the
failing read is on the `-wal` file
and not on the database file. Materializing the database cannot avoid
it.
Reported by a user against both 0.7.2 and 0.8.0-pre.10: `checkpoint()`
succeeds while the WAL holds frames
and then fails with `I/O error (pread): unexpected end of file` on every
checkpoint that follows, which
leaves a partial-sync replica unable to ever fold its WAL twice in a
row.
Every existing partial-sync test — Rust bindings and TS alike — opens
the replica at `:memory:`, which maps
to `MemoryIO`, so the entire partial-sync suite ran on the one IO
backend that is not affected. The new
tests all use a real file path. Added coverage:
| Test | Layer |
|---|---|
| `partial sync (checkpoint with empty WAL)` in
`bindings/javascript/sync/packages/native/promise.test.ts` | e2e through
the JS SDK against a local sync server |
| `test_sync_partial_checkpoint_with_empty_wal` in
`bindings/rust/src/sync.rs` | e2e through the Rust driver |
| `partial_sync_checkpoint_succeeds_when_main_wal_is_empty` in
`sync/engine/src/database_sync_engine.rs` | sync engine, over
`SparseLinuxIo` |
| `full_sync_checkpoint_succeeds_when_main_wal_is_empty` (control) |
same sequence over `PlatformIO`, passes before and after |
| `read_wal_salt_of_empty_wal_file_is_none_on_every_io` | pins the per-
backend behaviour of the failing read |
| `pread_reports_short_read_at_end_of_file` in
`sync/engine/src/sparse_io.rs` | 32-byte reads of 0-, 10- and 32-byte
files |
Each of those fails before the fix and passes after, except the full-
sync control, which exists to show the
failure is partial-sync-specific. The TS test was verified in both
directions by rebuilding the napi module
with `read_exact_at` restored and confirming the exact reported error.
The first commit is the reproductions on their own, so the failure is
visible in isolation before the fix.
Tests: `turso_sync_engine` 100 pass; `turso --features sync` 35 pass, 1
pre-existing ignore;
`promise.test.ts` 34 pass, 5 skipped (the pre-existing
`skipIf(LOCAL_SYNC_SERVER)` tests).
Note for reviewers: `94bc9b2` carries unrelated churn in two checked-in
generated files, produced by running
the local debug napi build — 46 version-string lines in `index.js`
(`0.8.0-pre.3` → `0.8.0-pre.10`, the
checked-in file was stale) and a missing `filePaths(): Array<string>`
declaration in `index.d.ts`. Happy to
strip both from the branch if preferred.
Driven with Claude Code (Opus 5). It located the root cause from the bug
report alone, wrote the
reproductions at the sync-engine, Rust-driver and JS-SDK layers, wrote
the `pread` fix, and verified each
test fails without the fix and passes with it. I reviewed the diff and
committed it.
Two model conclusions were checked against evidence rather than taken on
trust: that the failing read is
`read_wal_salt` (confirmed by tracing showing the second checkpoint
dying between two adjacent log
statements whose only intervening IO is that read), and that the bug is
independent of page materialization
(confirmed by a hole-free repro, which contradicted the "materializing
fixes it" part of the report).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-by: Pekka Enberg <penberg@iki.fi>
Closes#8930
## Summary
`push()` in `@tursodatabase/sync` (Node) used roughly 14–20x the size of
the change set in RSS. A user pushing a ~50 MB change set saw a +900 MB
RSS peak and had to set `pushOperationsThreshold` to avoid OOM kills in
CI. The dominant cost was not the sync engine but the napi boundary: the
serialized HTTP request body was handed to JavaScript as a plain
`Array<number>`, one element per byte.
This PR passes the body (and `FullWrite` content) across the boundary as
a napi `Buffer` instead, and drops the extra `Uint8Array` copy on the JS
side.
## Root cause
`JsProtocolRequest::Http { body: Option<Vec<u8>>, .. }` and `FullWrite {
content: Vec<u8> }` are fields of a `#[napi]` enum. napi-rs marshals
`Vec<u8>` as a JS array of numbers (the generated typing was `body?:
Array<number>`). V8 stores such an array at 8 bytes per element, so a 21
MiB JSON body became a ~170 MiB array before `run.ts` copied it again
with `new Uint8Array(requestType.body)` and undici buffered it once
more.
Everything else in the push path (decoded CDC row images, the
`BatchStep` vector, the JSON body, undici's copy) adds up to a few
multiples of the body, which is what remains after this change.
## Changes
- `bindings/javascript/sync/src/js_protocol_io.rs`: `Http.body` is
`Option<Buffer>`, `FullWrite.content` is `Buffer`. Both are built with
`Buffer::from(Vec<u8>)`, which takes ownership of the allocation without
copying.
- `bindings/javascript/sync/packages/common/run.ts`: pass the buffer
straight to `fetch`; a `Buffer` is already a `Uint8Array`.
- `bindings/javascript/sync/packages/native/index.d.ts`: the two
generated types updated to `Buffer`.
- `bindings/javascript/sync/packages/native/promise.test.ts`: new
regression test.
No sync-engine (Rust core) changes. The wasm package shares this Rust
code and its `write()` implementations already accept `Buffer |
Uint8Array`, so `FullWrite` needs no JS follow-up there.
## Measurements
Same test (`push()` of one 16 MiB blob, 21.3 MiB JSON body), same
machine, debug builds:
| Build | RSS growth during `push()` | Multiple of body |
|---|---|---|
| Without this change | 296 MiB | 13.9x |
| With this change | 83 MiB | 3.9x |
Standalone, holding 50 MiB of bytes as a JS `Array<number>` cost 1080
MiB of RSS on Node 26 versus 50 MiB as a `Uint8Array`, which matches the
user report almost exactly.
Closes#8635
The browser build runs the same napi module through emnapi, where
`globalThis.Buffer` does not exist, so creating a `Buffer` from Rust
fails with NotSupportBufferError and every sync test in chromium
errors out.
A `Uint8Array` carries the bytes just as cheaply on Node (napi-rs takes
ownership of the `Vec<u8>` and hands V8 an external ArrayBuffer) and
emnapi supports it in the browser, where it copies the bytes out of wasm
memory. The JS side already accepts `Buffer | Uint8Array` everywhere
these values are consumed.
Tests: sync bindings on node and browser
Fix `@tursodatabase/sync-wasm` file-backed replicas failing when
connecting to an MVCC database through OPFS.
The sync engine can open an MVCC logical-log file whose name is derived
by replacing the database filename extension with `.db-log`. The browser
wrapper did not register that path with the OPFS worker, causing
operations to fail with:
```
unexpected path <replica>.db-log: files must be created in advance for OPFS IO
```
This change:
- Makes the Rust sync engine the source of truth for all local files a
synced database may open.
- Exposes that list to the JavaScript binding before the sync connection
starts.
- Uses the same list when registering and unregistering OPFS files.
- Keeps the existing generated WASM entrypoints consistent without
duplicating filename rules.
- Adds browser coverage for switching a file-backed replica to MVCC
sync, writing data, closing it, and reopening it.
A fresh file-backed sync-wasm replica could not connect to a remote MVCC
database because OPFS requires every file to be registered before Rust
opens it.
Keeping the file list in Rust prevents the browser wrapper from drifting
from the sync engine when sidecars or filename rules change. It also
preserves the existing extension-replacement behavior for filenames that
do not end in .db.
Fixes#8516
Codex helped investigate the issue, trace the relevant Rust and
JavaScript paths, write the implementation and regression tests, and run
validation.
The proposed design was reviewed iteratively, especially where the file
list should live and how to avoid duplicating it in the sync-wasm
wrappers. That review led to keeping the list beside the Rust filename
rules and exposing it to the browser binding. The final changes and test
results were reviewed before submission.
Closes#8524
The dependency tree carried three esbuild copies, two of them in the
range GHSA-67mh-4wv8-2f99 and GHSA-g7r4-m6w7-qqqr name: 0.18.20 behind
the deprecated @esbuild-kit packages that drizzle-kit still pulls in, and
0.27.7 at the top level. A resolutions entry collapses all three to
0.28.2, which is outside both advisories.
Every workflow that touches bindings/javascript installs with yarn, so
package-lock.json was a second lockfile that nothing consumed and that
nothing kept honest -- it had drifted to esbuild 0.27.7 and to a
playwright version the resolutions block pins away from. Worse, npm
rewrites an existing yarn.lock into Yarn 1 format whenever it runs, so
the release script's `npm install` was silently downgrading the lockfile
that CI actually reads, and only the `yarn install` that followed put it
back. Remove the file, ignore it so it does not reappear, and drop the
npm install from the release script.
Tests: yarn install --immutable; yarn workspace @tursodatabase/database-common
build && test; yarn workspace @tursodatabase/database-wasm bundle (vite,
which is what consumes esbuild); yarn npm audit --all --recursive reports
no advisories, only deprecation notices.
Ever since the libSQL days, the batch API has had the same complaint:
you
could not get the result of each individual statement, and when a batch
failed you could not tell which statement failed — or what had already
taken effect. With Turso we have a blank slate, and it turns out the
protocol never was the limitation: a batch response carries complete
per-statement information (results, last insert rowid, error codes, and
the execution statistics `rows_read`, `rows_written`,
`query_duration_ms`; PROTOCOL.md §6.2, §8.4, §9.1). The drivers just
dropped it. This PR takes the opportunity to do it right.
Every driver now exposes one `batch()` API that returns everything the
protocol reports, per statement, in one HTTP round trip:
- **Per-statement results**: rows, affected row count, last insert
rowid, and the server-side execution statistics.
- **Failure visibility**: statements execute in order and stop at the
first failure; the error identifies the failing statement by index
*and* carries one entry per statement — the completed statement's
result, or null/None for the failing statement and the ones that never
ran. In a non-atomic batch the completed statements are committed, and
the caller can finally see exactly what took effect.
- **Atomic mode**: the transactional variant wraps the statements in
`BEGIN <mode>` / `COMMIT` with a conditional `ROLLBACK`, carried by
the
same single request.
Per driver:
- **JavaScript** (`serverless/javascript`, existing public API —
extended
compatibly): each `ResultSet` gains `lastInsertRowid`, `rowsRead`,
`rowsWritten`, `queryDurationMs`; the thrown `DatabaseError` gains
`batchIndex` and `batchResults`. `batch()` moves from the cursor
endpoint to a pipeline batch request because the cursor stream's
`step_end` does not carry the statistics. Non-atomic batches are now
gated on the previous statement succeeding — previously statements
after a failure kept executing server-side.
- **Rust** (new API, `bindings/rust` + `serverless/rust` in one commit
per the driver-parity rule): `Connection::batch` /
`Connection::transactional_batch`,
`BatchStatement`/`IntoBatchStatement`
inputs, `BatchResult` with stats accessors, and
`Error::BatchStatementFailed { index, error, results }`. The sync
driver shares the embedded `Connection`, so all three backends expose
the same API.
- **Python** (new API, `bindings/python` + `serverless/python` in one
commit): `Connection.batch(statements, mode=None)` on the DB-API
surface (sync, aio, and the sync-database driver via inheritance),
raising the classified DB-API exception with `batch_index` and
`batch_results` attributes.
The parity requirement itself is codified first, in
`serverless/conformance/differential/README.md` ("Driver API parity")
with a pointer from the AGENTS.md core principles.
**Deliberately skipped: Go.** The Go serverless driver is a plain
`database/sql` driver, and `database/sql` has no batch surface, so it is
less obvious what to do there: libsql-client-go's precedent is splitting
multi-statement SQL client-side (with a vendored ANTLR SQLite parser)
inside `Exec`, while the alternative is a driver-specific `Batch` API
outside the standard interface. That trade-off deserves its own
discussion and PR.
The batch behavior is property-tested: a `param_batch` operation in the
shared differential vocabulary (`spec/ops.json`) generates 1-4
parameterized statements — including planted failures and atomic modes —
and all three language harnesses (fast-check, hypothesis, hegel) assert
that the embedded and serverless drivers agree on every statement's
result, the failing index, and the partial results carried by the error.
Building those harnesses caught two real driver bugs before the tests
ever ran: the embedded JS driver had no batch error surface at all, and
the embedded Rust driver reported the connection's stale change counter
for row-returning statements inside a batch.
Follow-ups, out of scope here:
- Whether the JS `compat` (libsql-compat) layer should surface the new
per-statement `ResultSet` fields on success; it is kept libsql-shaped
here (the error path does preserve `batchIndex`/`batchResults`).
- Driver-wide preservation of `extended_code` on errors (today only the
Python serverless `ServerError` keeps it).
- A batch entry containing multi-statement SQL ("a; b") errors on the
embedded drivers but the server prepares only the first statement — an
embedded/serverless divergence worth its own discussion.
Also rides along in the JS commit: four env-gated integration tests
still
asserted positional access on expanded rows, which f52724d45 removed on
purpose; CI never runs those tests, so they had drifted.
Tested against a live libsql-server and against Turso Cloud: Rust 44
unit + 58 conformance tests plus the hegel parity property, Python 73
serverless + 236 embedded plus the hypothesis parity property,
JavaScript 42 integration tests plus the fast-check parity property, and
protocol-level coverage asserting a parameterized multi-statement batch
in a single pipeline POST.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Closes#8535
Raise the Vitest and Vite minimum versions and refresh both npm and Yarn locks. This also updates the vulnerable js-yaml, nanoid, postcss, and ws transitive resolutions named by the security report.
Tests: npm ci --ignore-scripts; yarn install --immutable --mode=skip-build; yarn workspace @tursodatabase/database-common test; npm audit --package-lock-only
Co-authored-by: pedro muniz <pedro.muniz.carlo@gmail.com>
Parameterized batches could produce different effects across embedded and
serverless drivers when a later bind value was invalid. Embedded Rust also
allowed cloned connections to interleave work with a batch, and managed
batches allowed transaction-control statements to escape their wrapper.
Rollback failures were hidden, while serverless Rust could retain a stale
last-insert rowid when COMMIT failed after a successful insert.
Validate every batch input before execution, reject transaction-control SQL
before opening a managed transaction, and hold an operation-wide gate for
embedded Rust batches. Preserve both the primary and rollback errors, and
carry successful statement rowids through serverless batch decoding even
when a synthetic transaction step fails. Reject malformed serverless batch
responses instead of treating incomplete transaction steps as success.
The protocol reports complete per-statement information for a batch —
results, last insert rowid, error codes, and the execution statistics
rows_read, rows_written, and query_duration_ms — but batch() dropped
most of it. Extend the batch API compatibly, in the serverless driver
and in the embedded driver (@tursodatabase/database, whose
DatabasePromise is shared by the wasm and sync drivers), per the driver
API parity requirement:
- Each ResultSet also carries lastInsertRowid, plus rowsRead,
rowsWritten, and queryDurationMs on the serverless driver (the
embedded engine does not report those per statement). The
lastInsertRowid key is present only on entries whose statement
inserted, so `"lastInsertRowid" in resultSet` detects an insert.
- The serverless batch() uses a pipeline batch request instead of the
cursor endpoint, because the cursor stream does not carry the
statistics, and gates each statement on its predecessor succeeding,
so execution stops at the first failure instead of running the
remaining statements against a failed batch — the embedded driver's
sequential semantics.
- The thrown error carries batchIndex (the zero-based index of the
failing statement) and batchResults (one entry per statement: the
completed statement's ResultSet, or null for the failing and skipped
ones; empty when a bind value fails to encode client-side before
anything is sent), so callers can tell exactly which statements took
effect.
- The libsql-compat batch() returns the full libSQL ResultSet shape —
lastInsertRowid and toJSON() included, matching @libsql/client, whose
batch() returns the same ResultSet as execute() — and both of its
batch entry points preserve batchIndex and batchResults on the
LibsqlError they throw.
The JavaScript conformance contract covers the per-statement detail
fields. Also update the serverless integration tests that still
asserted positional access on expanded rows, removed in f52724d45.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Keep core, sync-only, and MVCC file ownership visible beside the Rust path builders that define their names.
- Expose the complete path list before connection so OPFS registration and cleanup cannot drift from sync-engine behavior.
- Remove duplicated JavaScript path construction from every generated WASM entrypoint.
- Register MVCC logical-log files before OPFS-backed replicas switch journal modes, preventing connect and pull failures caused by unknown worker paths.
- Derive the log name with the same extension-replacement rule used by Rust, then reuse one file list for both opening and closing browser files.
- Exercise the real browser path against a file-backed MVCC server, including deferred connection, sync, close, and reopen.
A yield carries no pending I/O completion by design: core deliberately
does not store yields in io_completions, so no completion callback will
ever fire for one. The JS binding folded Yield into STEP_IO, and the
wasm driver handles STEP_IO by awaiting an I/O notification from the
OPFS worker. When a statement yielded while no I/O was in flight,
nothing ever notified the waiter, so the statement (and everything
queued behind the connection's exec lock) hung forever in the browser.
Node was unaffected only because its ioStep is a no-op.
Map Yield to STEP_SLEEP with a 1ms delay so the step loops re-step on a
timer instead of waiting for a notification that was never scheduled.
This mirrors the STEP_SLEEP approach from #8325 for busy_timeout and
needs no driver changes: both the native and wasm step loops already
handle STEP_SLEEP by sleeping and stepping again, which matches core's
contract that a yielded instruction simply re-executes on the next
step.
No regression test: per review, an injection-based test was rejected
and the bug cannot be reproduced from pure JavaScript. Every natural
yield source in core (btree cursor-restore TryAdvance, materialized
view populate, pager init lock, in-flight page reads, MVCC allocator
contention) needs async I/O in flight or cross-connection thread
contention, neither of which single-threaded JS can trigger through
the native binding, whose PlatformIO completes I/O synchronously.
Tests: cd bindings/javascript && yarn install && yarn workspace @tursodatabase/database-common build && yarn workspace @tursodatabase/database exec napi build --platform --esm --manifest-path ../../Cargo.toml --output-dir . && yarn workspace @tursodatabase/database run test && git checkout -- packages/native/index.js packages/native/index.d.ts
Fixes#8341
Syncing against an MVCC-mode database requires the sync engine to use
logical-log
pulls, but this was gated behind an opt-in flag (`logical_mvcc_pull`)
that the JS,
Python, Go, and react-native SDKs never exposed. Every SDK client
pulling from an
MVCC database bootstrapped a stale base and then failed with:
```
status=400 "MVCC incremental pull-updates requires stream_kind=mvcc_logical_log"
```
Even after plumbing the flag through, users would have to know their
database's
journal mode and configure the client accordingly/we don't want to force
a client to configure this flag.
The protocol is a property of the server, so the client should learn it
there.
## Solution
The server now advertises its pull protocol in every pull-updates
response.
The engine reads it on first contact and persists it in the sync
metadata:
- New `remote_pull_protocol` field in `DatabaseMetadata`: `unknown`,
`pages`,
or `mvcc_logical`. Old metadata files deserialize to `unknown` and are
migrated on load from the existing `logical_mvcc_pull_active` bool
whenever
the replica already holds a revision.
- `DatabaseSyncEngineOpts.logical_mvcc_pull` is now `Option<bool>`.
`None`
(the new default) auto-detects; `Some(true/false)` forces a protocol
and
remains available in every SDK as an escape hatch.
`Builder::with_logical_mvcc_pull`
keeps its signature.
- For servers that predate the header field, detection falls back to the
shape
of the advertised revision: MVCC revisions contain `log_offset`, WAL
diskless
revisions only `generation`/`wal_fragment_no`.
- A replica created with deferred bootstrap stays `unknown` until its
first
pull; that request is wire-identical to the existing no-revision page
request,
so the response tells us the protocol before any mode-specific
behavior kicks in.
- Partial sync or remote encryption combined with an MVCC remote is now
a hard
error at configuration/detection time.
### Deferred bootstrap ("converted to cloud sync later")
A replica created with deferred bootstrap has already committed to a
local
journal mode before the remote's protocol is knowable. When first
contact
detects an MVCC remote and the local database is still in WAL mode, the
engine now converts it in place with `PRAGMA journal_mode = 'mvcc'`
(core
already implements the full transition for populated databases: WAL
checkpoint, header rewrite, MvStore bootstrap over the existing btree)
before applying the remote base as replace-base. Local changes survive
via
the existing CDC replay, and the conversion is durable across reopens.
Without this, applying an MVCC-headered base into a WAL-mode process
would
leave the file header and the running journal mode disagreeing: the
process
keeps WAL semantics while the next open reads the MVCC header and starts
an
empty MvStore: essentially an uncoordinated journal mode flip across
restarts.
### CDC Guard
also added here: since `replace-base` preserves local data by replaying
the CDC log, so a database file that lived outside
the sync engine (user tables present but an empty CDC log before the
first sync) is rejected with a
descriptive error instead of silently dropping its rows.
Reviewed-by: Nikita Sivukhin (@sivukhin)
Closes#8057
The sync packages (Rust, Python, JavaScript, React Native, Go) only
rewrote libsql:// remote URLs to https://, so turso:// URLs were either
rejected or passed through unmodified and failed at request time. The
serverless packages already accept both schemes; normalize turso:// the
same way in every sync binding so the two URL forms are interchangeable.
Tests: normalize_base_url_schemes in bindings/rust, TestSyncNormalizeUrl
in bindings/go
The browser binding test jobs run inside the Microsoft Playwright
container, whose preinstalled browser binaries must match the
`playwright` npm package version resolved at install time. The caret
ranges in the wasm packages drifted to the newly released 1.62.0 while
the container is pinned at v1.61.0-jammy, so browserType.launch failed
to find the chromium executable and both browser test jobs failed.
Microsoft has not published a v1.62.0 container image yet (all
v1.62.0 tags 404 on mcr.microsoft.com), so the image cannot be bumped
to match the package. Instead, add a yarn resolution pinning playwright
to 1.61.0 to match the existing image. The resolution should be dropped
once the v1.62.0 image is published.
Fixes the "Test DB bindings on browser" and "Test sync bindings on
browser" failures in the Build & publish @tursodatabase/database
workflow.