tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
10.02k stars 262 forks source link

Getting an "unable to convert to ascii" error when trying to implement syncing with embedded replicas #438

Closed xinnks closed 1 year ago

xinnks commented 1 year ago

While using both the typescript client and rust crate to sync Turso with embedded replicas, the "unable to convert to ascii" error is always thrown, and the app breaks.

Reproduction

Use the example code provided in the the rust crate for Rust and typescript client for TypeScript. Provide all the required variables and run the code.

Current behaviour

For the TypeScript example this is the error log:

LibsqlError: : Write delegation: `status: InvalidArgument, message: "unable to convert to ascii", details: [], metadata: MetadataMap { headers: {"access-control-allow-credentials": "true", "access-control-expose-headers": "grpc-status,grpc-message,grpc-status-details-bin", "content-type": "application/grpc-web+proto", "date": "Mon, 02 Oct 2023 16:42:03 GMT", "fly-request-id": "01HBRM9AJN49H0SAFVV7FP450M-jnb", "via": "2 fly.io, 1.1 fly.io", "content-length": "0", "server": "Fly/e440b950 (2023-09-20)", "vary": "origin", "vary": "access-control-request-method", "vary": "access-control-request-headers"} }`
    at mapSqliteError (file:///Users/username/emb-replica-demo/node_modules/.pnpm/@libsql+client@0.3.5/node_modules/@libsql/client/lib-esm/sqlite3.js:286:16)
    at executeStmt (file:///Users/username/emb-replica-demo/node_modules/.pnpm/@libsql+client@0.3.5/node_modules/@libsql/client/lib-esm/sqlite3.js:203:15)
    at Sqlite3Client.execute (file:///Users/username/emb-replica-demo/node_modules/.pnpm/@libsql+client@0.3.5/node_modules/@libsql/client/lib-esm/sqlite3.js:55:16)
    at example (file:///Users/username/emb-replica-demo/sync.mjs:12:12) {
  code: '',
  [cause]: SqliteError: Write delegation: `status: InvalidArgument, message: "unable to convert to ascii", details: [], metadata: MetadataMap { headers: {"access-control-allow-credentials": "true", "access-control-expose-headers": "grpc-status,grpc-message,grpc-status-details-bin", "content-type": "application/grpc-web+proto", "date": "Mon, 02 Oct 2023 16:42:03 GMT", "fly-request-id": "01HBRM9AJN49H0SAFVV7FP450M-jnb", "via": "2 fly.io, 1.1 fly.io", "content-length": "0", "server": "Fly/e440b950 (2023-09-20)", "vary": "origin", "vary": "access-control-request-method", "vary": "access-control-request-headers"} }`
      at Database.prepare (/Users/username/emb-replica-demo/node_modules/.pnpm/libsql@0.1.24/node_modules/libsql/index.js:91:13)
      at executeStmt (file:///Users/username/emb-replica-demo/node_modules/.pnpm/@libsql+client@0.3.5/node_modules/@libsql/client/lib-esm/sqlite3.js:174:28)
      at Sqlite3Client.execute (file:///Users/username/emb-replica-demo/node_modules/.pnpm/@libsql+client@0.3.5/node_modules/@libsql/client/lib-esm/sqlite3.js:55:16)
      at example (file:///Users/username/emb-replica-demo/sync.mjs:12:12) {
    code: ''
  }
}

For the Rust example, here is the error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: WriteDelegation(status: InvalidArgument, message: "unable to convert to ascii", details: [], metadata: MetadataMap { headers: {"access-control-allow-credentials": "true", "access-control-expose-headers": "grpc-status,grpc-message,grpc-status-details-bin", "content-type": "application/grpc-web+proto", "date": "Tue, 26 Sep 2023 21:32:41 GMT", "fly-request-id": "01HB9PH54X6EN7Z211K10KCJQA-jnb", "via": "2 fly.io, 1.1 fly.io", "content-length": "0", "server": "Fly/e440b950 (2023-09-20)", "vary": "origin", "vary": "access-control-request-method", "vary": "access-control-request-headers"} })', src/main.rs:32:6
LucioFranco commented 1 year ago

Closing this as this error message indicates its from a version before we fixed replica auth.