Closed dankoster closed 1 month ago
Hi @dankoster, unfortunately FFI is not supported on Deno Deploy, so any library that depends on this capability doesn't work.
@magurotuna Thanks for the reply! Do you know if FFI on the roadmap for Deno Deploy? Will it be possible to use SQLite in the future?
Sorry to say that it's not on the roadmap. Deno Deploy aims to be secure and it achieves this by utilizing V8 isolation and Deno's permission model. However, once we allow FFI, that would break the security model, or alternatively we would need to very carefully redesign the entire architecture to ensure security.
In general, in case you want to rely on something outside JS, you may want to consider wasm, which is supported on Deno Deploy. Also, we offer Deno KV that is built into Deno and Deno Deploy so you can use it right now without the need to complex setup. It is not the same as SQLite, but I believe it covers a good portion of usecases you can do with SQLite.
Using a KV store would, paradoxically, over-complicate the data storage task I want to perform. I will explore the WASM approach for now and keep hosted SQL solutions in my pocket for the unlikely scenario where I need to scale up.
sqlite3 WebAssembly & JavaScript Documentation Index Connect to SQLite with the WASM-Optimized Module
@magurotuna Thank you for your help and thank you for being security conscious!
@magurotuna A WASM implementation is fairly useless on deno deploy if we don't have permission to write to the database file. Are ANY permissions configurable on deno deploy?
PermissionDenied - Requires write access to "./test.db", run again with the --allow-write flag
On Deno Deploy file system related operations are limited to a set of read operations, and write operations are not allowed. https://docs.deno.com/deploy/api/runtime-fs/ Basically a good mental model for Deno Deploy is a simple computational resource that can be invoked via HTTP, with very limited immutable file system attached. If you'd like to persist some data, Deno KV is the only option available within Deno Deploy, or for more general purposes consider using external storage services, like S3, GCS, etc.
Ok, thanks for the clarification! :)
Problem description
SQLite works great locally but fails when deploying to Deno Deploy with the following error, which hides the actual error.
Steps to reproduce
I made my repro public here: https://dash.deno.com/playground/old-moth-94
Expected behavior
No error when deploying.
Environment
Latest Deno Deploy (fails)
Local (works as expected):
Possible solution
Is this because
--unstable-ffi
is required? Is there a way to deal with this on Deno Deploy?Possible debugging: The stack trace points to ffi.ts:642 as the source of the error. That line does include the original exception, but the deployment output is not sufficiently verbose to reveal that information. If the verbosity cannot be increased then a next course of action may be to include the SQLite code directly instead of as a dependency and modify this line to have more verbose output.
Additional context
Fails in playground, deployctl, and github action.