-
Notifications
You must be signed in to change notification settings - Fork 161
Description
Summary
Using rivetkit/db/drizzle with actors on Cloudflare Workers fails at actor startup because @rivetkit/cloudflare-workers does not appear to provide either:
createSqliteVfs(), oroverrideDrizzleDatabaseClient()
As a result, the Drizzle database provider falls through to the KV/VFS path and throws:
SqliteVfs instance not provided in context. The driver must provide a sqliteVfs instance.Environment
rivetkit:2.1.6@rivetkit/cloudflare-workers:2.1.6drizzle-orm:0.44.2drizzle-kit:0.31.9wrangler:4.70.0
Expected Behavior
One of these should work on Cloudflare Workers:
rivetkit/db/drizzleshould work out of the box with@rivetkit/cloudflare-workers, or- the docs should clearly state that this combination is not currently supported
Ideally, the Cloudflare adapter would support actor-local Drizzle databases by either:
- supplying
createSqliteVfs()for the KV-backed SQLite path, or - implementing
overrideDrizzleDatabaseClient()using Cloudflare Durable Object SQLite storage
Actual Behavior
Actor startup fails with:
Uncaught Error: SqliteVfs instance not provided in context. The driver must provide a sqliteVfs instance.This happens during actor DB setup before the actor can serve requests.
Repro
Minimal actor setup:
import { actor } from "rivetkit";
import { db } from "rivetkit/db/drizzle";
import { sqliteTable, text } from "drizzle-orm/sqlite-core";
import migrations from "./drizzle/migrations";
const testTable = sqliteTable("test_table", {
id: text("id").primaryKey(),
});
export const myActor = actor({
db: db({
schema: { testTable },
migrations,
}),
actions: {
ping: async () => "pong",
},
});Cloudflare worker setup:
import { createInlineClient } from "@rivetkit/cloudflare-workers";
import { registry } from "./registry";
const rivet = createInlineClient(registry);
export const ActorHandler = rivet.ActorHandler;
export default {
fetch: rivet.fetch,
};Then invoking an actor action causes startup to fail with the SqliteVfs instance not provided in context error.
Investigation
From local inspection of the published packages:
rivetkitcore includesoverrideDrizzleDatabaseClientsupport in the actor driver interfacerivetkit/db/drizzleexpects either:- a driver-provided
sqliteVfs, or - a driver-provided Drizzle override
- a driver-provided
@rivetkit/cloudflare-workers@2.1.6does not appear to implement either path
So this seems to be a gap between Rivet core’s DB integration seam and the Cloudflare Workers adapter.
Question
Is this combination expected to be supported right now?
If not, could the docs call that out explicitly?
If yes, is the intended fix:
- adding
createSqliteVfs()to the Cloudflare adapter, or - adding
overrideDrizzleDatabaseClient()backed by Durable Object SQLite storage?