tursodatabase / libsql-client-ts

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

`createClient` using embedded replica blocks on I/O #99

Open CodingDoug opened 1 year ago

CodingDoug commented 1 year ago

createClient should not block the caller at all, nor throw errors unrelated to the validity of the parameters it receives. An example of a thrown error can be seen in #98.

Seems related to https://github.com/libsql/libsql-js/issues/22

Instead, the SDK should try to connect asynchronously after client creation, and defer any errors to first async method call on the client. Either that, or there should be a new client factory function that returns a promise instead of a client object and operates entirely async.