tursodatabase / tursodatabase/libsql-client-ts

Unfriendly error when trying to use an embedded replica against a database that doesn't support it

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Client version 0.3.5-pre.10

The error below contains the relevant information, but it's difficult to understand. Also, the error code isn't populated with something meaningful (empty string). Ideally in this case, there should be a unique code and instructions on how to remedy the situation (turso db update and a minimum required version of the db).

/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/sqlite3.js:334
        return new api_js_1.LibsqlError(e.message, e.code, e);
               ^

LibsqlError: : Write delegation: `status: Internal, message: "protocol error: received message with invalid compression flag: 84 (valid flags are 0 and 1) while receiving response with status: 401 Unauthorized", details: [], metadata: MetadataMap { headers: {"access-control-allow-origin": "*", "vary": "origin", "vary": "access-control-request-method", "vary": "access-control-request-headers", "transfer-encoding": "chunked", "date": "Thu, 21 Sep 2023 20:48:39 GMT", "server": "Fly/e440b950 (2023-09-20)", "via": "1.1 fly.io", "fly-request-id": "01HAWR0Y9CPPF2MP25A8R30J15-chi"} }`
    at mapSqliteError (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/sqlite3.js:334:16)
    at executeStmt (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/sqlite3.js:251:15)
    at _createClient (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/sqlite3.js:60:9)
    ... 6 lines matching cause stack trace ...
    at __awaiter (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/dist/index.js:5:12) {
  code: '',
  [cause]: SqliteError: Write delegation: `status: Internal, message: "protocol error: received message with invalid compression flag: 84 (valid flags are 0 and 1) while receiving response with status: 401 Unauthorized", details: [], metadata: MetadataMap { headers: {"access-control-allow-origin": "*", "vary": "origin", "vary": "access-control-request-method", "vary": "access-control-request-headers", "transfer-encoding": "chunked", "date": "Thu, 21 Sep 2023 20:48:39 GMT", "server": "Fly/e440b950 (2023-09-20)", "via": "1.1 fly.io", "fly-request-id": "01HAWR0Y9CPPF2MP25A8R30J15-chi"} }`
      at Database.prepare (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/libsql/index.js:91:13)
      at executeStmt (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/sqlite3.js:222:28)
      at _createClient (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/sqlite3.js:60:9)
      at _createClient (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/node.js:39:47)
      at createClient (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/node_modules/@libsql/client/lib-cjs/node.js:28:12)
      at /Users/doug/work/chiselstrike/libsql/libsql-client-node2/dist/index.js:23:50
      at Generator.next (<anonymous>)
      at /Users/doug/work/chiselstrike/libsql/libsql-client-node2/dist/index.js:9:71
      at new Promise (<anonymous>)
      at __awaiter (/Users/doug/work/chiselstrike/libsql/libsql-client-node2/dist/index.js:5:12) {
    code: ''
  }
}

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

Start by tracing the error mapping shown in lib-cjs/sqlite3.js, especially mapSqliteError, and the underlying failure in libsql/index.js. Determine how this embedded-replica incompatibility is identified and define the expected unique error code and remediation wording, including the required database version and turso db update guidance.】【。

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.