212 Commits

Author SHA1 Message Date
Pekka Enberg
a820079e8e Turso 0.9.0-pre.1 2026-10-15 12:17:20 +03:00
Pekka Enberg
2829ee1662 Turso 0.8.0 2026-09-28 12:42:08 +03:00
Pekka Enberg
632b58d522 Turso 0.8.0-pre.14 2026-09-28 09:09:16 +03:00
Pekka Enberg
64b8ef5742 Turso 0.8.0-pre.13 2026-09-25 10:54:27 +03:00
Pekka Enberg
e7e77e5957 Turso 0.8.0-pre.12 2026-09-22 17:01:34 +03:00
Pekka Enberg
e9fe414212 bindings/javascript: stop the sync loops in the concurrent-updates test
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.
2026-09-18 14:11:35 +03:00
Pekka Enberg
57e4809dac bindings/javascript: pass sync test options as second argument
Vitest 4 removed the test(name, fn, options) signature, so the sync
native test file failed to load.
2026-09-16 19:19:26 +03:00
Pekka Enberg
24682aec7d bindings/javascript: update vitest to 4.1.11
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.
2026-09-16 18:57:18 +03:00
Nikita Sivukhin
7cc973fbe3 Turso 0.8.0-pre.11 2026-09-11 09:37:12 +01:00
Nikita Sivukhin
6b88d2b456 Merge 'Fix empty wal checkpoint sync' from Nikita Sivukhin
`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
2026-09-10 21:39:41 +01:00
Nikita Sivukhin
161a908647 fix compilation 2026-09-10 22:01:37 +02:00
Nikita Sivukhin
94bc9b269c add ts test 2026-09-10 16:59:19 +02:00
Nikita Sivukhin
fee48fec6f simplify 2026-09-10 16:55:57 +02:00
Pekka Enberg
342dfbe267 Turso 0.8.0-pre.10 2026-09-09 09:06:19 +03:00
Mikaël Francoeur
56208cc073 Turso 0.8.0-pre.9 2026-09-08 10:24:02 -04:00
Pekka Enberg
09ec06a3ab Merge 'sync/bindings: fix memory issues with JS/NAPI buffers' from Preston Thorpe
## 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
2026-09-04 13:45:14 +03:00
Pekka Enberg
9384daad3b Turso 0.8.0-pre.8 2026-09-04 07:17:43 +03:00
Pekka Enberg
fccc31918d sync/JS-bindings: send sync request bodies as Uint8Array
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
2026-09-03 20:41:11 +03:00
PThorpe92
536ad5b57c sync/JS-bindings: pass sync HTTP bodies across napi as buffer 2026-09-02 16:23:40 -07:00
Amp
d2e40e82f0 bindings/js: update vulnerable development dependencies
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>
2026-08-29 14:51:38 +03:00
Pekka Enberg
277ddd050b Turso 0.8.0-pre.7 2026-08-21 08:50:47 +03:00
Pekka Enberg
e8aef1923d Turso 0.8.0-pre.6 2026-08-19 10:18:12 +03:00
Pekka Enberg
a3e6627ebc Turso 0.8.0-pre.5 2026-08-19 07:18:14 +03:00
Pekka Enberg
ce276e4218 Turso 0.8.0-pre.4 2026-08-11 15:55:09 +03:00
Nikita Sivukhin
201ea4fdce fix JS bindings 2026-08-11 13:15:26 +02:00
Pekka Enberg
ed15b13f8e Turso 0.8.0-pre.3 2026-08-06 15:59:00 +03:00
PThorpe92
106cf991fc sync: auto-detect the remote pull protocol 2026-07-27 16:13:28 -07:00
Pekka Enberg
47b0635417 Turso 0.8.0-pre.2 2026-07-26 11:55:13 +03:00
Nikita Sivukhin
ef41321622 add test 2026-07-24 10:46:09 +02:00
Nikita Sivukhin
4b8518232c Turso 0.8.0-pre.1 2026-07-21 01:16:04 +04:00
Nikita Sivukhin
149635b0c8 use transactionAsync instead of transaction 2026-07-17 16:09:13 +02:00
Nikita Sivukhin
b7c223d273 add todo 2026-07-17 15:30:02 +02:00
Nikita Sivukhin
6931576650 wip 2026-07-17 15:28:14 +02:00
Nikita Sivukhin
8a5b50dc8a fix tests 2026-07-17 15:03:18 +02:00
Nikita Sivukhin
a86208e996 wip 2026-07-17 14:59:46 +02:00
Nikita Sivukhin
5f60c5a8ee adjust signature of transaction API for TS/JS tursodb async SDK 2026-07-17 14:54:29 +02:00
Pekka Enberg
e7cb62a8bd Turso 0.7.0 2026-07-13 18:12:11 +03:00
Pekka Enberg
4b18962902 Turso 0.7.0-pre.22 2026-07-13 17:38:12 +03:00
Pekka Enberg
3c2148f734 Turso 0.7.0-pre.20 2026-07-12 12:50:15 +03:00
Pekka Enberg
d115b414ad Merge 'Drop the beta warning' from Glauber Costa
0.7 ships next week, and Turso now runs in production at multiple
organizations — the top-of-page "this software is in BETA, use caution
with production data" warning no longer reflects reality, and it's the
first thing every visitor reads.
## What changed
- **About**: the ⚠️ BETA warning blockquote is gone. In its place, a
one-line status note: Turso runs in production today, with a pointer to
the FAQ for where the project stands on the way to 1.0.
- **FAQ "Is Turso Database ready for production use?"**: now opens with
"Yes" and the production users, followed by the testing story (DST,
Antithesis). The honest caveats stay, but softened: not yet 1.0, some
features explicitly experimental, and backups recommended as "the same
discipline you would apply to any database" rather than as a data-loss
threat.
- **New FAQ "How compatible is Turso Database with SQLite?"**: we're not
at 100% yet, COMPAT.md tracks the details, the gap is closing quickly,
and full compatibility is a requirement for 1.0.
- **libSQL FAQ**: still flatly said "libSQL is production ready, Turso
Database is not", contradicting the rest of the page. Now: both run in
production; libSQL is more battle-tested, Turso Database is where
development effort is focused.
The goal is to neither scare nor oversell: no data-loss warning up top,
but the README still says clearly that we are pre-1.0 and that some
SQLite differences remain.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-by: Mikaël Francoeur (@LeMikaelF)

Closes #7735
2026-07-12 08:52:00 +03:00
Pekka Enberg
9f13ffbecd Turso 0.7.0-pre.19 2026-07-12 08:39:31 +03:00
PThorpe92
816b4e707a fix replaying local changes after applying remote snapshot in V1 Pages pull 2026-07-07 09:23:35 -07:00
Pekka Enberg
11ab464138 Turso 0.7.0-pre.18 2026-07-05 19:30:07 +03:00
Glauber Costa
1679062d8c docs: drop the beta warning for 0.7
Turso runs in production at multiple organizations, so the "this
software is in BETA, use caution with production data" warning no
longer reflects reality. It appeared in the main README, was
copy-pasted in 11 bindings READMEs (what users see on npm, PyPI, and
pkg.go.dev), and was printed by tursodb at every shell startup.

- README: remove the warning blockquote from About, leaving a one-line
  status pointer. Rewrite the production-readiness FAQ to lead with
  production use and the testing story, keeping the honest caveats in
  softer form: not yet 1.0, some features experimental, keep backups
  as with any database. Add a FAQ on SQLite compatibility (gap tracked
  in COMPAT.md, closing quickly, required for 1.0), and fix the libSQL
  FAQ, which still claimed Turso Database is not production ready.
- bindings READMEs: replace the warning with the same softened status
  line, linking to the FAQ.
- cli: remove the startup banner line entirely, matching the SQLite
  shell.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 10:56:57 -05:00
Nikita Sivukhin
0fd4fb8b7b Turso 0.7.0-pre.14 2026-06-29 11:58:42 +04:00
Pekka Enberg
5fa8222f39 Turso 0.7.0-pre.13 2026-06-25 17:06:04 +03:00
Pekka Enberg
92e8498d26 Turso 0.7.0-pre.12 2026-06-25 16:40:54 +03:00
Pekka Enberg
2e1a41772b Turso 0.7.0-pre.11 2026-06-25 10:22:15 +03:00
Pekka Enberg
1ebe80ff22 Turso 0.7.0-pre.10 2026-06-18 20:48:10 +03:00
Nikita Sivukhin
93dddea459 Turso 0.7.0-pre.9 2026-06-17 22:27:57 +04:00