Write and run job workers
A worker is the code that performs a process's service tasks. The Workers tab lets you author them in TypeScript right in the browser and run them as sandboxed Deno subprocesses, with a live fleet view (status, throughput, completed/failed, uptime, restarts) and streamed logs.
Running workers needs Deno installed on the host (the
denobinary onPATH, or pointed to byNANOBPMN_DENO_BIN). Without it you can still author and export worker code; only starting a worker is unavailable. Install Deno from https://deno.com.
A worker is a directory with a worker.ts that declares a handler:
import { defineWorker } from "@nanobpm/worker";
defineWorker({
type: "my-job",
maxParallelJobs: 10,
async handle(job) {
// job.variables holds the activated job's variables.
return { result: 42 }; // resolves -> completes the job with { result: 42 }
// or: job.fail("boom") / job.error("CODE", "msg")
},
});
A 90s IDE, on purpose
The worker editor is deliberately styled after the integrated development environments of the early-to-mid 1990s — Borland Delphi, Microsoft Visual Basic — where the wiring was invisible and you focused only on what can't be automatically connected. The BPMN model is the form; the engine binds tasks to workers by job type; the transport, retries, timeouts, and dependency resolution are handled for you. You write only the handler body. That ethos drives the editor's code intelligence:
- Full IntelliSense for the worker SDK, offline.
defineWorker, thejobobject (job.variables,job.complete,job.fail,job.error,job.jobKey,job.processInstanceKey, …) and every option auto-complete and type-check with no network access. - Types for any npm package. Import any package —
import _ from "lodash",import { ... } from "@camunda8/orchestration-cluster-api"— and the editor fetches its type definitions on the fly so completion, hovers, and signatures light up. This needs network access and degrades silently to SDK-only IntelliSense when offline. - Reusable logic across files. Split a worker into multiple files and
import { helper } from "./helper.ts"— siblings resolve with full types. For logic shared across every worker, drop a module into the workspace Shared library (the📚 Shared libraryentry below the worker list) and import it anywhere with the@lib/alias —import { fmtMoney } from "@lib/money.ts". There is nothing to configure: the alias resolves in the editor, at runtime, and in an exported app.