tursodatabase / libsql-client-ts

TypeScript/JavaScript client API for libSQL
https://docs.turso.tech/sdk/ts/quickstart
MIT License
289 stars 37 forks source link

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

Open CodingDoug opened 1 year ago

CodingDoug commented 1 year ago

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: ''
  }
}