tursodatabase/libsql-client-ts

UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate

Opened this issue · 2 comments

I'm running LibSQL server locally and using this sdk to connect to it. The following is my code:

import { createClient } from "@libsql/client"

const client = createClient({
  url: "libsql://localhost:8080",
  authToken: "",
})

const start = Bun.nanoseconds()

const queries = 1000
for (let i = 0; i < queries; i++) {
  await client.execute(
    "SELECT * FROM users;",
  );
}

const delta = (Bun.nanoseconds() - start) / 1000000;

console.log("Total time:", delta, "ms")
console.log("Avg time:", delta / queries, "ms")

I have spun up a docker container running the libsql-server, and when I use Postman to send queries it works perfectly fine, but when I run the above code; it throws the following error:

There has been an error while retrieving the database type.
Debug information:
- URL: https://localhost:8080
- Response Status Code: N/A
UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate
 path: "https://localhost:8080/v1/jobs"
UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate
 path: "https://localhost:8080/v2/pipeline"

Bun v1.1.18 (Linux x64)

I'm also not sure why it says the provided url is https://... when it's actually libsql://...?!

Any idea what I'm doing wrong?

Any comments on this 😕

@abdurahmanshiine Doesn't look to be a Bun specific issue.

I get a somewhat similar issue running under node v20. If it's blocking you from working locally you could try "http://localhost:8080" instead of "libsql://localhost:8080". This seems to get around the initial error.

Edit: Ah right, libsql:// URLs use TLS by default. Update your config as such to disable TLS or use the above suggested http:// scheme.

const client = createClient({
  url: "libsql://localhost:8080",
  authToken: "",
  tls: false
})