Resident process: Node with SQLite

Use the Node connector when the coordinator and forked workers run under Node. It wraps node:sqlite DatabaseSync behind the shared synchronous SqliteDriver contract.

Requirements

Node 22.6 or newer can run TypeScript worker entry points through built-in type stripping. Compile the application and point workerPath at JavaScript when using an older Node release.

Install

pnpm add yieldstar @yieldstar/core @yieldstar/sqlite-runtime @yieldstar/worker-invoker

Database and event loop

import { SqliteEventLoop } from "@yieldstar/sqlite-runtime";
import { createSqliteDb } from "@yieldstar/sqlite-runtime/node";

export const db = createSqliteDb({ path: "./.db/local.sqlite" });
export const eventLoop = new SqliteEventLoop(db);

Worker and application

Use the same WorkflowRunner, SQLite clients, createWorkflowWorker, event-loop, and local SDK wiring shown on the Bun connector page. Only the createSqliteDb import changes.

import pino from "pino";
import { createLocalSdk } from "yieldstar";
import { createWorkflowInvoker } from "@yieldstar/worker-invoker";
import { eventLoop } from "./shared";
import type { Router } from "./shared";

const logger = pino();
const workerPath = new URL("./worker.ts", import.meta.url).href;
const invoker = createWorkflowInvoker({ workerPath, logger });

eventLoop.start({ onNewEvent: invoker.execute, logger });
const sdk = createLocalSdk<Router>(invoker);
const result = await sdk.triggerAndWait({ workflowId: "my-workflow" });
eventLoop.stop();

Run a TypeScript application with node app.ts on a supported Node release. Both the parent and forked worker use Node, and SQLite operations go through the real node:sqlite connector.