Skip to content

@rivetkit/cloudflare-workers does not support rivetkit/db/drizzle actor databases on Cloudflare Workers #4367

@bam4564

Description

@bam4564

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(), or
  • overrideDrizzleDatabaseClient()

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.6
  • drizzle-orm: 0.44.2
  • drizzle-kit: 0.31.9
  • wrangler: 4.70.0

Expected Behavior

One of these should work on Cloudflare Workers:

  1. rivetkit/db/drizzle should work out of the box with @rivetkit/cloudflare-workers, or
  2. 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:

  • rivetkit core includes overrideDrizzleDatabaseClient support in the actor driver interface
  • rivetkit/db/drizzle expects either:
    • a driver-provided sqliteVfs, or
    • a driver-provided Drizzle override
  • @rivetkit/cloudflare-workers@2.1.6 does 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions