Skip to content

docs(workflow): add singleton workflows how-to - #900

Merged
CahidArda merged 8 commits into
mainfrom
docs/workflow-singleton
Oct 7, 2026
Merged

CahidArda merged 8 commits into
mainfrom
docs/workflow-singleton

Conversation

@sancar

@sancar sancar commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Adds workflow/howto/singleton.mdx, a how-to for running at most one workflow run at a time by reusing the same workflowRunId. It's listed in the nav after "Cancel a Run".

Covers two patterns, and what the caller gets back in each case:

  • Keep the running one: a trigger while a run is in progress throws a QstashError (400, a workflow already exists, can not initialize a new one with same id). Otherwise the trigger returns { workflowRunId }.
  • Replace the running one: client.cancel(id) returns { cancelled: 1 | 0 }, then client.trigger starts the new run.

Requires @upstash/workflow 1.4.0 (upstash/workflow-js#214) and upstash/qstash-server#1129. The page notes workflow-py isn't supported yet.

Roadmap: https://github.com/orgs/upstash/discussions/192

Document running at most one workflow run at a time by reusing the same
workflowRunId (requires @upstash/workflow 1.4.0):

- keep the running one: a trigger while a run is in progress is rejected
- replace the running one: client.cancel, then client.trigger

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mintlify

mintlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
upstash 🟢 Ready View Preview Oct 7, 2026, 1:48 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@context7

context7 Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Docs7 for upstash.com

Result Status Action
Deployment ✅ Ready Open preview
Content review ✅ Passed. No problems found. View findings

Commit 568de13 · Updated 2026-10-07 13:50 UTC · View build details

@context7
context7 Bot temporarily deployed to Docs7 Preview: docs/workflow-singleton October 7, 2026 10:53 Destroyed
@sancar
sancar requested a review from CahidArda October 7, 2026 11:09
@CahidArda
CahidArda requested a balanced review from Copilot October 7, 2026 11:35
Copilot stopped reviewing on behalf of CahidArda due to an error October 7, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds documentation for “singleton workflows” to help users ensure only one workflow run is active at a time by reusing a fixed workflowRunId.

Changes:

  • Added a new how-to page describing singleton workflow patterns (reject new trigger vs cancel-and-replace).
  • Updated docs indexes/exports to include the new page (search listing, full LLM dump, docs navigation JSON).
File Description
workflow/​howto/​singleton.mdx New documentation page explaining singleton workflow behavior and usage patterns.
llms.txt Adds the new page to the docs search/listing index.
llms-full.txt Adds the full content of the new singleton workflows page to the consolidated docs dump.
docs.json Adds the new page to the workflow/howto navigation structure.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +49 to +55
} catch (error) {
if (error instanceof Error && error.message.includes("a workflow already exists")) {
console.log("nightly-sync is already running, skipping");
} else {
throw error;
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to rely on the text message as 400 can be mixed with other cases.

Comment thread workflow/howto/singleton.mdx Outdated
Comment thread workflow/howto/singleton.mdx Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@context7
context7 Bot temporarily deployed to Docs7 Preview: docs/workflow-singleton October 7, 2026 12:06 Destroyed
…message

Match QstashError with status 400 instead of the error text, and confirm a
run with the id is in progress with client.logs, since 400 also covers
other invalid trigger requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@context7
context7 Bot temporarily deployed to Docs7 Preview: docs/workflow-singleton October 7, 2026 12:13 Destroyed
sancar and others added 2 commits October 7, 2026 16:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@context7
context7 Bot temporarily deployed to Docs7 Preview: docs/workflow-singleton October 7, 2026 13:50 Destroyed
@CahidArda
CahidArda merged commit e1c7da3 into main Oct 7, 2026
3 of 4 checks passed
@CahidArda
CahidArda deleted the docs/workflow-singleton branch October 7, 2026 13:54

This branch was successfully deployed

1 active deployment
Docs7 Preview: docs/workflow-singleton — 568de134 Deployed Oct 7, 2026 by context7[bot]
staging — 568de134 Deployed Oct 7, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants