waitForJob onStatus also fires on the terminal poll: Sume SDK

In @sume-com/sdk, onStatus runs on every status read, including the last one. Use it for progress and take the result from the job waitForJob returns.

5 min readSume
All posts

onStatus in waitForJob is called on every status read, and that includes the terminal one. So it can tell you a job is failed or canceled as well as completed. Use it to draw progress, and take the outcome from the job that waitForJob returns, because the helper makes one more read after the last poll.

This matters most for teams moving off a video API such as OpenAI's Videos API, which OpenAI's deprecations page lists for removal on 2026-09-24 with no replacement named (read 2026-10-06). Progress UI code written against one vendor's status words often marks a job as done on the first terminal-looking callback.

What the callback receives

The callback gets two arguments: the sume_status value and the whole status payload. In the SDK source the payload type is SumeJobStatusSnapshot, and its comment names the useful fields: next_action, next_poll_after_seconds, and queue.

onStatus arguments (read 2026-10-06)
ArgumentTypeUse
statusqueued, processing, completed, failed, canceledDrive a progress label
snapshot.next_poll_after_secondsnumber or nullShow when the next check runs
snapshot.queue.statestring enumShow waiting or processing
snapshot.next_actionpoll_status, fetch_result, inspect_eventsTell the user what happens next

A minimal progress hook

The returned value is the job record from GET /v1/jobs/:id. It resolves for any terminal status, so check job.status there, not inside the callback.

import { createSumeClient, waitForJob } from "@sume-com/sdk";

const client = createSumeClient({ apiKey: process.env.SUME_API_KEY! });
const jobId = process.argv[2]!;

const job = await waitForJob(jobId, {
  client,
  onStatus: (status, snap) => {
    console.log(status, snap.queue.state, snap.next_poll_after_seconds);
  },
});

console.log("final:", job.status);

What to avoid

  • Do not render a success state inside onStatus: failed and canceled arrive through the same callback.
  • Do not treat a callback as a fresh poll you control. The SDK sets the pace: a 2 second floor, raised by the server's next_poll_after_seconds.
  • Do not read the artifact list from the snapshot. Read it from the returned job, or from GET /v1/jobs/:id/result once result_ready is true.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume