Deploy and read SQLite database inside Edge Functions

I’m trying to deploy a Remix application to Netlify’s Edge Functions, following the template in this repo. I’m using a read-only SQLite database as my data store, and I’d like to read from it inside the Edge Functions.

I’ve gotten this to work locally using netlify dev, where my generated functions read the SQLite database from the filesystem. Setting my DATABASE_URL environment variable in Netlify’s online configuration to the same value as local (or really any file path) causes the deployed functions to crash:

This edge function has crashed

An unhandled error in the function code triggered the following message:
The deployment failed while serving the request.

Connection details
Netlify internal ID: 01G20YT4RKK06H1GPN0DAVFFMG

Checking the Edge Functions tab on Netlify just has an endless spinner—the logs never load.

I think the problem is that my Edge Functions don’t have a way to access the database file. I’ve found other support threads (here and here) that seem to support this hypothesis, but they are for regular Netlify functions. They reference zip-it-and-ship-it as a possible solution, but that appears to be for Node.js where Edge Functions use Deno. And those threads didn’t seem to reach a clear conclusion.

I found configuration in the docs for including files in a Function, but I couldn’t find any equivalent options for Edge Functions.

I know Edge Functions (and using them with Remix) are in beta, and that loading binary files in a regular Function is not well supported right now. Is there a way to load a SQLite database file in an Edge Function, without hosting it somewhere else and accessing it over the network? Are there plans to support such a setup as Edge Functions evolve? Is what I’m looking for supported in regular Functions using the above configuration?

Other info:
Netlify site id: 09fdb2c2-0def-404b-8201-ce5cb2237db8
netlify.toml:

[build]
command = "remix build"
publish = "public"

[dev]
command = "remix watch"
port = 3000

[[headers]]
for = "/build/*"

[headers.values]
"Cache-Control" = "public, max-age=31536000, s-maxage=31536000"
1 Like

Hey @justin.renjilian,

At the moment, there’s no easy way to bundle a file with the Edge Functions. That’s a great feature request and we’ll get that filed.

But at the moment, sounds like the own way for you to do that would be something that you say you don’t want to do - deploy it somewhere else and fetch it in your Edge Function. We’re still getting a final confirmation and we’ll keep you posted.

@hrishikesh is there any update on support for this?

It would be great for Netlify to have parity with Cloudflare’s D1, but in the short-term even just the ability to read from the filesystem (whether it’s SQLite, JSON, YAML etc) would be a good start.

Hey @ryantownsend,

Nothing at the moment, I’m afraid. We recently worked and added Edge Function support for our High Performance Edge. Now that Edge Functions are running across all of our CDN, we can now focus on making the experience better which can include feature requests like these.