Scan your whole stack
From OX Research Newsroom
Are you using @vite-hub/workflow?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.6.1
@vite-hub/workflow was last scanned on 27 Nov 2026 at version 0.6.1. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.6.1 LATEST | 27 Nov 2026 | No rules fired |
| 0.6.0 | 26 Nov 2026 | No rules fired |
| 0.5.1 | 25 Nov 2026 | No rules fired |
| 0.5.0 | 24 Nov 2026 | Not shown |
| 0.4.1 | 20 Nov 2026 | Not shown |
Findings for v0.6.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.6.1; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
@vite-hub/workflow discovers named long-running work and exposes one provider-neutral API for starting and inspecting runs.
Use a Workflow when the application needs a run id, durable state, retries, cancellation, or resumable work. Use Queue when background delivery is enough and the application does not need to inspect a run.
pnpm add @vite-hub/workflow
Then install the dependency required by the selected driver:
| Provider | Additional dependency | Durable state |
|---|---|---|
| Cloudflare Workflows | None in application code | Cloudflare owns run state. Without the binding, only vite dev runs inline; a Worker fails with WORKFLOW_R0036. |
| Vercel Workflow | @vercel/functions; add workflow@5.2.3 and @workflow/builders@5.0.6 for native durable definitions (versions) |
Native definitions survive function restarts; plain handlers run inline. |
| OpenWorkflow | None. @vite-hub/workflow depends on openworkflow and postgres |
Postgres Default Database, else a local SQLite file. |
Importing the provider-neutral package root does not load OpenWorkflow types. Worker lifecycle helpers live at @vite-hub/workflow/openworkflow.
On Node and Docker, ViteHub selects OpenWorkflow when driver is not set, also in vite dev with the node host. OpenWorkflow reads its storage at runtime. Set workflow.sqlite.path or workflow.postgres.url to select the storage yourself. An explicit value takes precedence over ambient storage environment variables. Without it, OPENWORKFLOW_SQLITE_PATH selects SQLite, then OPENWORKFLOW_POSTGRES_URL selects Postgres. Then, when the app has a Postgres Default Database, OpenWorkflow uses its connection URL (getPostgresConnectionUrl() from @vite-hub/database). A DATABASE_URL alone is not used, the same as for Queue and Realtime. If it contains a postgres:// or postgresql:// URL and storage would otherwise fall back to SQLite, resolution fails with WORKFLOW_OPENWORKFLOW_DATABASE_URL_IGNORED. Before upgrading, set OPENWORKFLOW_POSTGRES_URL or workflow.postgres.url to that same URL, or add a Postgres Default Database pointing to the existing database. Keep the same schema and namespace to retain queued and sleeping runs. Select workflow.sqlite.path or OPENWORKFLOW_SQLITE_PATH to choose local storage intentionally. Other DATABASE_URL schemes do not trigger the error. vite dev keeps runs in the local SQLite file unless workflow.remote is true, so a dev server never runs the runs of a shared database. A configured environment declaration must resolve to a value; missing configuration rejects before opening a backend. With no storage configuration or storage environment variables, OpenWorkflow uses .vitehub/data/openworkflow.sqlite.db, and the server logs at boot that other instances do not see those runs.
The former workflow.database option was never connected to Named Databases. It now rejects instead of silently selecting fallback storage. Replace it with workflow.sqlite.path or workflow.postgres.url.
// server/workflows/onboard-user.ts
import { defineWorkflow } from "@vite-hub/workflow";
export default defineWorkflow<{ email: string }>({
handler: async ({ payload, id, provider }) => {
const idempotencyKey = `onboard-user:${payload.email}`;
const user = await upsertUser(payload.email, { idempotencyKey });
await sendWelcomeEmail(user.email, { idempotencyKey: `${idempotencyKey}:welcome-email` });
return { id, provider };
},
});
Both external operations receive keys derived from stable input. Preserve that idempotency when adding side effects so retrying a completed operation does not duplicate it.
ViteHub discovers server/workflows/<name>.ts, folder workflows such as server/workflows/onboard-user/index.ts, and src/<name>.workflow.ts. The file or folder path is the Workflow name. defineWorkflow() takes one object and no name. Pass the name to the runtime helpers.
The handler gets one object with payload, id, name, provider, sleep, createSignal, and steps. Pass the payload type as the type argument of defineWorkflow(). ViteHub writes the names and payload types to .vitehub/workflow.d.ts, so startWorkflow("onboard-user", payload) checks both.
A folder Workflow runs its numbered files as steps. 01.create-user.ts becomes steps.createUser:
// server/workflows/onboard-user/index.ts
import { defineWorkflow } from "@vite-hub/workflow";
export default defineWorkflow<{ email: string }>({
handler: async ({ payload, steps }) => {
const user = await steps.createUser(payload);
return await steps.sendWelcome(user);
},
});
// server/workflows/onboard-user/01.create-user.ts
export default async function createUser(input: { email: string }) {
return { id: `user:${input.email}`, email: input.email };
}
// server/workflows/onboard-user/02.send-welcome.ts
export default async function sendWelcome(user: { id: string, email: string }) {
return { userId: user.id, welcomeSent: true };
}
The Vite Integration writes .vitehub/workflow.d.ts. A step name shared by multiple folders accepts only inputs that all those steps accept and can return any of their result types. A call to a step that has no file is a type error. At runtime, only the current folder's steps are available. Include .vitehub/workflow.d.ts in your TypeScript project; vite-hub includes it through .vitehub/types.d.ts.
// server/workflow-runtime.ts
import type {
ResolvedWorkflowOptions,
WorkflowDefinitionRegistry,
} from "@vite-hub/workflow";
import {
setWorkflowRuntimeConfig,
setWorkflowRuntimeRegistry,
} from "@vite-hub/workflow/runtime/state";
const postgresUrl = {
kind: "env-variable",
source: { kind: "env", name: "OPENWORKFLOW_POSTGRES_URL" },
} as const;
export const workflowConfig = {
driver: "openworkflow",
postgres: { url: postgresUrl },
} satisfies ResolvedWorkflowOptions;
const workflowRegistry = {
"onboard-user": () => import("./workflows/onboard-user.ts"),
} satisfies WorkflowDefinitionRegistry;
export function installWorkflowRuntime() {
const url = process.env.OPENWORKFLOW_POSTGRES_URL;
if (!url) throw new Error("OPENWORKFLOW_POSTGRES_URL is required");
setWorkflowRuntimeConfig({
...workflowConfig,
postgres: { ...workflowConfig.postgres, url },
});
setWorkflowRuntimeRegistry(workflowRegistry);
}
For a standalone Vite app, install Nitro 3 before adding its server plugin:
pnpm add -D nitro@^3.0.261103-rc
// vite.config.ts
import { hubWorkflow } from "@vite-hub/workflow/vite";
import { nitro } from "nitro/vite";
import { defineConfig } from "vite";
import { workflowConfig } from "./server/workflow-runtime.ts";
export default defineConfig({
nitro: { serverDir: "./server" },
plugins: [hubWorkflow(workflowConfig), nitro()],
});
hubWorkflow() adds Workflow discovery and host output, but no server. Nitro gives the app its server and reads the routes in server/. Without nitro(), a plain Vite build fails with Cannot resolve entry module index.html. vitehub({ workflow: workflowConfig }) includes Nitro and installs the driver config and registry in the server, so an app that uses it does not need installWorkflowRuntime().
The Vite config, application process, and worker below share one driver config. The runtime installer also registers the same definitions in both processes. Set driver explicitly when the deployment target should not decide it. Otherwise ViteHub selects Cloudflare on Cloudflare hosting, OpenWorkflow on Node and Docker, and Vercel on Vercel. Deno requires an explicit driver or OpenWorkflow storage for builds; development and Agent-only Workflows can run inline. Netlify cannot infer a driver.
OpenWorkflow accepts one storage choice: postgres.url or sqlite.path. Hosted credentials belong in Server Env, not source code.
startWorkflow() only enqueues an OpenWorkflow run, and a worker executes it. With hubWorkflow() or vitehub(), the generated Nitro startup plugin of a Node or Docker server calls installOpenWorkflow(nitroApp). When the registry has discovered Workflow or Agent files, it loads OpenWorkflow from the server bundle and starts one worker. With only inline Workflows, it does not resolve or open OpenWorkflow storage or start a worker. The worker executes 10 runs at once; set workflow.worker.concurrency to change it. Each Agent turn uses two runs: the turn and its recovery run. The worker stops when Nitro closes or the process gets SIGTERM. Several servers can run a worker on the same Postgres database. Servers that start together set up the OpenWorkflow schema one at a time, so they do not fail with duplicate key value violates unique constraint. A server tries a Postgres advisory lock (pg_try_advisory_xact_lock) in a short transaction, and waits without a connection when another server holds it. OpenWorkflow does not export its migrations, so they run on their own connection while the lock transaction holds another. The server that gets the lock first checks for that second connection and stops with WORKFLOW_OPENWORKFLOW_SETUP_CONNECTION_UNAVAILABLE when it gets none in 10 seconds, then holds the lock until the setup ends. OpenWorkflow claims each run with FOR UPDATE SKIP LOCKED, so one worker executes it. When setup or the worker start fails, the server reports the error and tries again, with a delay that grows to 30 seconds, until it works or the server closes. WORKFLOW_OPENWORKFLOW_DATABASE_URL_MISSING and WORKFLOW_OPENWORKFLOW_DATABASE_URL_IGNORED stop the retries, because only a configuration change fixes it. WORKFLOW_OPENWORKFLOW_SETUP_CONNECTION_UNAVAILABLE (no second connection in 10 seconds) is retried, because a full pool frees connections later. installOpenWorkflow() resolves to true when the worker runs.
Every worker registers the discovered Workflow Definitions of the build registry when it starts, and any worker can claim a run. So OpenWorkflow runs only those definitions. The registry has each discovered Agent Workflow and its invocation recovery Workflow, so Agent turns are durable OpenWorkflow runs. The startup registry also installs the generated Agent State resolver and Capability loaders, so a fresh worker can restore persisted Channel deliveries without loading an Agent route first. A turn of an Agent that is not discovered fails with WORKFLOW_AGENT_NOT_DISCOVERED. A definition that code registers later, such as an inline createWorkflow(name, handler), runs inline in the request process, with metadata.mode set to "inline" and a warning. In vite dev, a changed Workflow file replaces the worker; the old backend stays open until the old worker finishes its runs.
Set workflow: { worker: false } to keep the servers from starting a worker. Then start one worker in a separate long-lived process:
// worker.ts
import { startOpenWorkflowWorker } from "@vite-hub/workflow/openworkflow";
import { installWorkflowRuntime } from "./server/workflow-runtime.ts";
installWorkflowRuntime();
const worker = await startOpenWorkflowWorker();
Keep this process running while it should consume queued runs, and do not start a worker per request. A separate worker executes the discovered definitions that it loads from the same registry. startOpenWorkflowWorker() installs SIGINT and SIGTERM handlers. If the host owns shutdown, await worker.stop() from its shutdown hook.
// server/api/onboard.post.ts
import { getWorkflowRun, startWorkflow } from "@vite-hub/workflow";
import { defineEventHandler, readBody } from "h3";
import { installWorkflowRuntime } from "../workflow-runtime.ts";
installWorkflowRuntime();
export default defineEventHandler(async (event) => {
const payload = await readBody<{ email: string }>(event);
const [startError, started] = await startWorkflow("onboard-user", payload);
if (startError) throw startError;
const [error, run] = await getWorkflowRun("onboard-user", started.id);
if (error) throw error;
return run;
});
startWorkflow() returns [error, run]: a normalized acknowledgement with an id, provider, and status. getWorkflowRun(), cancelWorkflow(), resumeWorkflow(), and the start, getRun, and cancel methods of a handle also return [error, data]. A provider failure, an unsupported option, or an invalid delay is error; its code is a WorkflowResultErrorCode. A config error, such as an unknown Workflow name, throws. When you pass { id }, that id is the run id on Cloudflare, OpenWorkflow, and inline runs, and a second start with the same id returns the first run. getWorkflowRun() returns normalized run and step state, including timestamps, attempts, and results when the provider supplies them. A failed run has error: { message, name?, code? }, safe to send as JSON, on every provider. metadata keeps provider data and no longer holds the error. Every provider reports the same statuses: a sleeping or waiting run reports running, a Cloudflare terminated run reports cancelled, and a run id that does not exist reports unknown.
To set your own id, pass { id }. On Cloudflare, start with a letter, a digit, or _, then use only letters, digits, -, and _, up to 100 characters. startWorkflow() returns the error WORKFLOW_CLOUDFLARE_RUN_ID_INVALID for another id. Inspection queries the binding because existing instance ids can follow different rules.
The other runtime helpers are:
deferWorkflow() starts a run after the response, through waitUntil. It returns nothing and logs a failure. Call startWorkflow() when you need the run id.cancelWorkflow() cancels a Cloudflare run with instance.terminate(), a native Vercel run, or a pending or running OpenWorkflow run. A finished run keeps its status, and a missing run reports unknown.resumeWorkflow(token, value) sends value to a run that waits on context.createSignal(), or resumes a Workflow DevKit hook token on Vercel.createWorkflow() creates a named handle with start, defer, getRun, and cancel methods.Unsupported provider operations fail with WORKFLOW_OPERATION_UNSUPPORTED; ViteHub does not pretend that an inline run was cancelled or resumed.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.