CoAkka Runtime · Bun 3.3.2

CoAkka Runtime · Bun cheat sheet

Find the task, copy the short pattern, then open the verified full file when lifecycle or failure handling matters.

Version and package

Terminal
bun add [email protected]
Connector
[email protected]; Bun 1.3.14+; ESM imports from the package root.
Core generation
3.3. The first two connector numbers identify the Core generation; the last is the connector revision.
Native identity
Commit f9e5a632d2d046a5b4e89d5ce0c9042aee5c7b45, ABI 1 in the verified package.
Package targets
macOS ARM64, Linux ARM64/x64 and Windows ARM64/x64. Read support as connector version + OS + CPU + evidence; do not infer beyond the tuple.

Embedded request/reply

Pattern
const runtime = BunRuntimeHost.start({
  systemName: "orders",
  nodeId: "orders-1",
  routes: [localRoute("orders.quote")],
});
try {
  runtime.registerPayloadHandler("orders.quote", quote);
  const reply = await runtime.askPayload("checkout", "orders.quote", payload, 2000);
} finally {
  await runtime.close();
}

Omit network to preserve Core's Embedded default. Open the complete first-run file.

Outcomes, deadletters and OneWay

Reply
askPayload, askJson or askTyped resolves with a correlated terminal response.
Deadletter
DeadletterError.deadletter carries reason, original envelope, generation, endpoint attempts and failure facts. Do not parse error text.
Timeout/cancel
A separate failure boundary. Do not retry side effects without an idempotency contract.
OneWay
sendOneWayTyped / sendOneWayJson has no business reply. Admission observability does not turn it into request/reply.
Terminal stream
submitRequest... + terminalEvents() separates submit from await over the same runtime contract.

Look up Envelope, Ask, OneWay and Deadletter.

Direct peer

Service
network: networkBun("0.0.0.0", 19321, "pricing.internal", 19321),
routes: [localRoute("orders.quote")],
Caller route
network: outboundOnlyNetwork(),
routes: [{
  target: "orders.quote",
  strategy: RouteStrategy.SINGLE_OWNER,
  endpoints: [{ host: "pricing.internal", port: 19321, weight: 1, flags: 0 }],
}],

Bind is where the listener opens; advertise is what the peer can reach. A topology owner supplies generation-based snapshots. CoAkka Runtime does not claim automatic service discovery or Kubernetes membership.

Open the full two-process example · Look up failover and retry

File Lane

  1. Compute FileLane.sha256(sourcePath).
  2. The receiver calls openOwned and prepareReceiveGrant.
  3. Move the grant through a trusted control plane; the sender calls submitSend(grant.toSendSpec(...)).
  4. Wait for terminal SEND and RECEIVE records and check completed plus result.
  5. Record outcomes, forget both records, then await close().

Copy the runnable example · Look up bounds, security and failures

Stream Lane

  1. The publisher calls openOwned and sets maxFrameBytes plus mailboxFrames.
  2. Call push for each frame, then end; treat false as mailbox pressure.
  3. The subscriber uses the grant and receive window, then calls poll for copied frames.
  4. Run mailbox loops and blocking waits in a Worker or dedicated process; never share a lane owner across Workers.
  5. Wait for terminal PUBLISH/SUBSCRIBE records, check results, forget and close.
  6. Use pressure snapshots as app-policy input; do not turn them into an unbounded retry loop.

Copy the runnable example · Look up flow control and pressure

Monitor and effective state

enableMonitor: true
Enables extra collection before startup. Confirm with runtime.monitor.isEnabled().
runtime.monitor.snapshot()
Copied health and stats at the read point.
awaitNext(timeoutMs)
A deadline-bounded Promise for a refresh signal; null only means no signal in the window.
runtimeStartupConfig()
Applied startup defaults, provenance and accepted facts.
runtimeConfig() / runtimeNetworkConfig()
Actual generation, routes, overload, bind and network participation.
runtimeSnapshot()
A combined diagnostic view. Never log secrets or transfer tokens with it.

Run the Monitor lesson · Look up Operations & Evidence

Integration checklist

Open task-oriented configuration reference.