upstash-workflow

Implements three-layer async workflows with Upstash Workflow and QStash in Next.js codebases.

74|11|Updated Jul 4, 2024
One-click install
npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill upstash-workflow-opensourceagi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: upstash-workflow
Source: https://github.com/OpenSourceAGI/qwksearch-research-agent/tree/main/apps/qwk-in-lobe/.agents/skills/upstash-workflow
Command: npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill upstash-workflow-opensourceagi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @upstash/workflow, and includes references (resource) components.

What problem does it solve? Building reliable background jobs with Upstash Workflow and QStash requires handling rate limits, workflow step limits, and idempotent retries, which is error-prone without a consistent architectural pattern. ## Core Features & Use Cases - Three-Layer Architecture: Standardizes workflows into entry point (process-), pagination with fan-out (paginate-), and single-item execution (execute-*) layers. - Dry-Run Mode: Preview statistics on how many items would be processed before triggering any side effects. - Fan-Out & Flow Control: Split large batches into chunks and tune per-layer parallelism and rate limits to respect external API constraints. - Use Case: Generate AI welcome messages for thousands of agents by paginating through the database, filtering already-processed agents, and executing one generation task per agent with controlled concurrency. ## Quick Start Use the upstash-workflow skill to scaffold a new three-layer workflow that processes users with dry-run support and fan-out pagination.

Frequently Asked Questions about upstash-workflow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an Upstash Workflow in a Next.js app?

Create a workflow class with static trigger methods using the Upstash Client, then define route handlers with serve() from @upstash/workflow/nextjs. Follow the three-layer pattern: a process entry point, a paginate layer with fan-out, and an execute layer handling one item per invocation.

How do I handle large batches with Upstash Workflow?

Use the fan-out pattern in the pagination layer: split item lists exceeding CHUNK_SIZE (default 20) into chunks and recursively re-trigger the paginate workflow for each chunk. This avoids hitting workflow step limits on large pages.

What is flowControl in Upstash Workflow?

flowControl configures concurrency per workflow endpoint using a key, parallelism, and ratePerSecond. Entry points typically use parallelism 1 to prevent duplicate batch triggers, while execution layers use parallelism 5-10 based on downstream API rate limits.

Why does my Upstash Workflow lose data when processing multiple items?

Upstash deduplicates context.run() calls by step name, so reusing the same step name in a loop drops results. Use unique step names like `workflow:execute:${item.id}` for each item processed in parallel.

How do I test Upstash Workflows before running them in production?

Implement a dryRun mode in the entry point that returns statistics (totalEligible, toProcess, alreadyProcessed) without triggering side effects. Write integration tests covering both the dry-run path and the full execution path, then smoke-test with a small batch.

What environment variables does Upstash Workflow require?

All workflows require APP_URL as the base URL for workflow endpoints and QSTASH_TOKEN for QStash authentication. QSTASH_URL is optional and only needed when using a custom QStash endpoint.