Skip to content

How can a late status response avoid moving a completed job back to running?

Serialize status reads for each job where possible, and reject observations that started before a newer accepted observation. Preserve a confirmed terminal state against late nonterminal replies. AISwapLab does not expose a documented job revision counter, so do not invent one from response arrival time.

DESIGN A CLEAR API PRODUCT EXPERIENCEAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Give reads local sequence numbers; Define allowed view changes; Exercise crossed responses.
Workflow diagram: Give reads local sequence numbers → Define allowed view changes → Exercise crossed responses. Read the article for evidence and limits.

Completion order is not observation order

Two browser components or overlapping refreshes can read the same job at different moments. The older read may return last. A simple setState call can replace a download button with a spinner even though no new generation event occurred.

What to do next

  1. 01

    Give reads local sequence numbers

    Allocate a monotonically increasing sequence when your application starts each read for one job. Track the highest sequence accepted for that job, separately from reads for other jobs or projects.

  2. 02

    Define allowed view changes

    Make confirmed completed and failed states terminal in your display reducer unless a deliberate reconciliation path establishes a correction. Treat unrecognized states as needing attention rather than guessing they mean progress.

  3. 03

    Exercise crossed responses

    Use controlled fixtures that hold a running response while allowing a later completed response through. Release the held response and verify it cannot clear the completed result, credit receipt or download action.

A concrete example

Illustrative example: read 31 captures running, while read 32 captures completed and returns immediately. Read 31 arrives seconds later. The interface retains completed because its local observation sequence is older; no provider ordering field is assumed.

Before you call it ready

  • Cross running and completed replies.
  • Open two status consumers together.
  • Keep terminal receipts after a stale refresh.

When to stop or choose another method

Stop automatic state replacement when observations disagree about terminal outcomes; retain evidence and route the discrepancy to your reconciliation workflow.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation