Turso with local db file
I wanted to try out Turso's syncURL feature and for that it creates a local db file to read from and syncs any written data remote first before it writes it locally.
However, I am not getting that far due to the following issue:
LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls
Deno code:
The script has all permissions by deno run -A main.ts.
Based on the error file: is simply not supported since Deno is allowing only web standard APIs?
Any other way to allow this? I am just suprised this isn't working since the use case seems acceptable.5 Replies
Based on the documentation, Deno supports fetching
file:
URLs as of Deno 1.16. However, it only supports absolute file URLs, which means that fetch("./some.json")
will not work. If you want to fetch some resource relative to the current module, you would want to use import.meta.url
as the base. Here's an example from the documentation:
However, it's important to note that permissions are applied to reading resources, so an appropriate --allow-read
permission is needed to be able to read a local file. Fetching locally only supports the GET
method, and will reject the promise with any other method. A file that does not exist simply rejects the promise with a vague TypeError
.
In your case, it seems like the file:
URL is not supported by the libsql
client you're using. This is not a limitation of Deno itself, but rather the specific library. You might want to check the library's documentation or reach out to its maintainers for more information on how to use local files with it. 🦕if I run this with bun all works just fine. So it seems that the issue is not
libsql
but Deno
or do I miss anything?the error message reads:
error: Uncaught LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls
GitHub
GitHub - libsql/libsql-client-ts: TypeScript/JavaScript client API ...
TypeScript/JavaScript client API for libSQL. Contribute to libsql/libsql-client-ts development by creating an account on GitHub.
and I guess with "client" it means Deno
this seems to be the issue: https://github.com/libsql/libsql-client-ts/issues/67
GitHub
Deno compatible local client · Issue #67 · libsql/libsql-client-ts
Hey I was very interested in learning how to use Turso on my most recent Deno project. I resorted to making a Deno compatible client for local development as Deno only had support for the web versi...