Skip to content

feat(next): accept Promise<Queue[]> for queues#48

Open
omarzeineddine-ai wants to merge 1 commit into
pontusab:mainfrom
omarzeineddine-ai:feat/next-async-queues
Open

feat(next): accept Promise<Queue[]> for queues#48
omarzeineddine-ai wants to merge 1 commit into
pontusab:mainfrom
omarzeineddine-ai:feat/next-async-queues

Conversation

@omarzeineddine-ai

Copy link
Copy Markdown

Problem

Closes #46

The Next.js adapter only accepted queues: Queue[]. Apps that collect their queues asynchronously (the issue author has 40+ queues behind an async helper) had no way to pass them without blocking module evaluation.

Solution

queues now also accepts Promise<Queue[]>:

export const { GET, POST, PUT, PATCH, DELETE } = workbench({
  queues: loadQueues(), // Promise<Queue[]>
  basePath: "/admin/jobs",
});
  • Sync usage is unchanged — the handler is still built eagerly, exactly as before.
  • With a promise, the fetch handler is built once the promise resolves; requests arriving earlier await it.
  • A rejected queues promise surfaces on each request (Next renders a 500) instead of becoming an unhandled rejection that can take the server down before any request lands.

Tests

Added packages/next/src/index.test.ts covering sync queues, promised queues, single resolution across handlers/requests, and rejection behavior. Verified with bun test, tsc --noEmit, tsup build, and biome lint in packages/next.

Apps that collect queues asynchronously (e.g. via an async registry
helper) previously had to block or work around the sync-only queues
field. The adapter now also accepts a promise: the handler is built
once the promise resolves, requests arriving earlier wait for it, and
a rejected promise surfaces on each request instead of crashing the
server as an unhandled rejection.

Sync usage is unchanged and still builds the handler eagerly.

Closes pontusab#46
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@omarzeineddine-ai is attempting to deploy a commit to the Pontus Abrahamsson's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Async queues option for nextjs adapter

1 participant