Skip to content

One crash-safe write

The escalation boundarySDKconditionalsignal_key

The row, its facets and the resume timer commit with the workflow's checkpoint in one write. A crash leaves all of it or none of it.

The situation

A workflow that creates a ticket in one call and then waits in another has a gap. A crash between the two leaves a ticket nobody is waiting on, or a wait with no ticket. Routers that claim by facet can also see a row before its metadata lands.

The recipe

workflows/inspect-part.ts
import { Durable } from '@hotmeshio/hotmesh';
import { conditional, type LTEnvelope } from '@hotmeshio/long-tail';
export async function inspectPart(envelope: LTEnvelope) {
const { serialNumber, orderId } = envelope.data;
const { workflowId } = Durable.workflow.workflowInfo();
const result = await conditional<{ pass: boolean; notes?: string }>(`inspect-${workflowId}`, {
role: 'inspection',
type: 'inspection',
subtype: 'visual',
priority: 2,
metadata: { serialNumber, orderId },
envelope: { instructions: 'Check the weld seam and the label' },
timeout: '8h',
});
return { type: 'return' as const, data: { serialNumber, result } };
}

Passing the config to conditional writes the escalation inside the workflow’s checkpoint. The row’s signal_key is the signal id, so every resolve surface resumes this run in place.

The guarantee

One commit holds the row, every metadata facet, the signal_key and the timer. A claim-by-facet router reads a complete row from its first visible moment. There is no create activity to retry and no resolve activity on the way back: resolving the row and waking the workflow is one guarded transaction. See Conditional.