tursodatabase / tursodatabase/libsql-client-ts

Client Crashes in Offline Mode When Server is Stopped

Open
#293 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
576
Forks
69
PR merge metrics
No merged PRs in 30d

Description

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/client version: 0.14.0
  • Node.js version: 22.4.0
  • OS: Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with the provided createClient configuration, using syncUrl, offline mode, and a stopped server. Start at the createClient entry point and trace the offline local execute path; done means the CREATE TABLE operation completes without a crash when the sync server is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.