All skills
upstash avatar

/upstash-qstash-js

@36daab8
by upstashupstash/skills27 stars
7

Work with the @upstash/qstash TypeScript/JavaScript SDK, an HTTP-based message queue, task scheduler, and background job system for serverless and edge runtimes (Next.js, Vercel, Cloudflare Workers, Deno, Node.js). Use when publishing messages to HTTP endpoints or URL groups, running background jobs without a long-running worker process, scheduling with cron expressions, delaying messages, building FIFO queues with parallelism and flow control, configuring retries and callbacks, handling a dead letter queue (DLQ), deduplicating messages, fanning out to multiple endpoints, verifying QStash webhook signatures (Next.js App Router, Pages Router, and Edge Runtime), running a local QStash dev server, or migrating regions. Also use when the user asks for a serverless cron job, async task queue, job scheduler, delayed delivery, webhook delivery with retries, or event-driven messaging between services.

Use this Skill: https://skilld.dev/gh/upstash/skills/upstash-qstash-js

This session only. Nothing lands on disk.

advanceddeduplication.md

≈563 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Message Deduplication

Prevent duplicate message delivery within a 90-day window using deduplication IDs.

Why Deduplication?

Duplicate messages can occur when:

  • User retries a failed request
  • Network issues cause message resubmission
  • Application logic triggers multiple publishes for the same event

Deduplication ensures QStash accepts but doesn't enqueue duplicate messages.

Deduplication Methods

deduplicationId

Provide a custom identifier to detect duplicates:

import { Client } from "@upstash/qstash";

const client = new Client({ token: process.env.QSTASH_TOKEN! });

await client.publishJSON({
  url: "https://api.example.com/webhook",
  deduplicationId: `order-${orderId}-payment`,
  body: { orderId, status: "paid" },
});

If a message with the same deduplicationId was published in the last 90 days, the new message is accepted but not enqueued.

Use cases:

  • Order processing: order-${orderId}
  • User events: user-${userId}-signup
  • Payment transactions: payment-${transactionId}

contentBasedDeduplication

Automatically generate a deduplication ID from message content:

await client.publishJSON({
  url: "https://api.example.com/webhook",
  contentBasedDeduplication: true,
  body: { userId: "123", event: "signup" },
});

The hash includes:

  • All headers (except authorization)
  • Request body
  • Destination URL

Deduplication Window

Deduplication IDs are stored for 90 days. After this period, a message with the same ID can be delivered again.

Response Handling

When a duplicate is detected, the response includes the original message ID:

const result = await client.publishJSON({
  url: "https://api.example.com/webhook",
  deduplicationId: "order-123",
  body: { order: "data" },
});

if (result.deduplicated) {
  console.log("Duplicate detected");
  console.log("Original message ID:", result.messageId);
}

Best Practices

  • Use descriptive, deterministic deduplication IDs
  • Include relevant context in custom IDs: ${entity}-${id}-${action}
  • Don't rely on deduplication for critical data consistency
  • Monitor deduplicated messages in logs to detect issues
  • Document your deduplication strategy for team reference

Source: SKILL.md on GitHub

No alerts17d3 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill provides comprehensive documentation and implementation guides for the Upstash QStash JS SDK. It includes a local development feature that automatically downloads and executes the official QStash CLI binary. While this involves remote code download and execution, it originates from the trusted vendor. The skill also processes external webhooks, creating a surface for indirect prompt injection, which is mitigated by built-in signature verification instructions.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

Signed by skilld at 36daab8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 days ago.

Activeupdated last month
metadata
{
  "author": "Upstash",
  "homepage": "https://upstash.com"
}

README badge

README badge for upstash/skills/upstash-qstash-js