Menu

Multi-step flows break in two places — here they are
📰

Multi-step flows break in two places — here they are

DEV Community: database·OBSIDIAN Studio·12 days ago
#sGDgDSVW
#devtodatabase#devto#dev#approval#retry
Long article (732 words) — no AI summary yet.
Reading 0:00
15s threshold

A lead arrives, an approver signs off, a record gets registered. Three steps. The code that moves a record from step to step is usually fine.

What breaks first is the part nobody writes down: what happened, in what order, and who was allowed to do it. After that, two things fail in production — the transition that runs twice, and the approval that runs under the wrong role.

Break point 1: the transition has no key of its own

Every hand-off between steps needs an identifier that survives a retry. Not the database row id (it does not exist yet), not the timestamp (it changes on retry). Something derived from the business event:

// the same approval, sent twice, must register one record const key = `${approval.request_id}:${approval.step}:${approval.version}` ;

const existing = await db . transitions . findByKey ( key ) ; if ( existing ) return existing ; // replay, not a second write

await db . transitions . insert ( { key , . . . approval } ) ; await queue .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.