libsql-client-ts
libsql-client-ts copied to clipboard
Client Crashes in Offline Mode When Server is Stopped
Description
When running the client in offline mode, the application crashes when the server is stopped. My understanding is the offline mode should allow local database operations without requiring an active connection to the sync server.
Steps to Reproduce
import { createClient } from "@libsql/client";
async function example() {
const config = {
url: process.env.URL ?? "file:local.db",
syncUrl: "http://localhost:8084",
offline: true,
};
const db = createClient(config);
await db.execute(
"CREATE TABLE IF NOT EXISTS guest_book_entries (comment TEXT)"
);
}
example();
Stop the sync server while client is running.
Expected Behaviour
The client should operate in offline mode without a crash.
Actual Behaviour
The application crashes with the following error:
2025-01-29T21:14:30.093225Z ERROR tower_http::trace::on_failure: response failed classification=Error: error trying to connect: tcp connect error: Connection refused (os error 111) latency=1 ms
/home/xxx/libsqltest/node_modules/@libsql/client/node_modules/libsql/index.js:116
const stmt = databasePrepareSync.call(this.db, sql);
^
Error: WriteDelegation(status: Unavailable, message: "error trying to connect: tcp connect error: Connection refused (os error 111)", details: [], metadata: MetadataMap { headers: {} }
Caused by:
0: error trying to connect: tcp connect error: Connection refused (os error 111)
1: tcp connect error: Connection refused (os error 111)
2: Connection refused (os error 111))
Environment
@libsql/clientversion:0.14.0- Node.js version: 22.4.0
- OS: Linux
The libsql panic also takes down the node server too.