Skip to content

feat(vercel): vercel queues - #16

Merged
pi0 merged 16 commits into
mainfrom
feat/vercel-queues-local-dev
May 21, 2026
Merged

pi0 merged 16 commits into
mainfrom
feat/vercel-queues-local-dev

Conversation

@RihanArfan

@RihanArfan RihanArfan commented May 13, 2026 •

Copy link
Copy Markdown
Collaborator

Support @vercel/queue registerDevConsumer() to enable passing queue triggers and consumers to register allowing bypassing registration via vercel.json. Exposes hooks for frameworks using env-runner to pass a consumer method, and triggers.

Summary by CodeRabbit

  • New Features

    • Local dev support for Vercel Queues: per-topic consumer registration, HMR-safe handler replacement, shared client reuse, and safe no-op behavior with a one-time warning if the queue SDK is missing or incompatible.
  • Documentation

    • Vercel runner docs updated: dev-time queue delivery, NODE_ENV defaulting to "development", and clarified that region env vars are intentionally not defaulted.
  • Chores

    • Added a public dev-facing Vercel queue entry and an optional peer dependency for the Vercel queue SDK.
  • Tests

    • Updated tests and fixtures to reflect NODE_ENV propagation and non-defaulted region vars.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 13, 2026 •

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a Vercel local-queues dev bridge with lazy SDK loading and HMR-safe per-topic handlers, generalizes build exports for nested runner modules, unifies fetch header forwarding, defaults worker NODE_ENV to "development", and updates docs, package exports, tests, and fixtures.

Changes

Vercel Queue Dev Bridge

Layer / File(s) Summary
Build and package configuration for queue module
build.config.mjs, package.json
Build mapping now supports ./runners/<name>/<sub> with runner as default file; package.json adds ./runners/vercel/queue-dev export and declares @vercel/queue as an optional peer dependency (^0.2.0).
Vercel queue-dev bridge implementation
src/runners/vercel/queue-dev.ts
Adds VercelQueueDevConsumer (topic, optional retryAfterSeconds, handler: MessageHandler) and registerVercelQueueConsumer() implementing per-topic slots, HMR-safe in-place handler replacement, shared QueueClient reuse, lazy @vercel/queue import via ensureSdk(), and graceful no-op fallback with a one-time warning.
Vercel runner environment and fetch updates
src/runners/vercel/worker.ts, src/runners/vercel/runner.ts
Worker defaults NODE_ENV to "development" and removes defaulting for VERCEL_REGION/NOW_REGION; VercelEnvRunner.fetch now forwards the original input and always merges headers via init in a single path.
Documentation and tests/fixtures
AGENTS.md, test/fixtures/app-env.mjs, test/vercel.test.ts
Adds queue-dev to the Vercel runner architecture and inventory, documents NODE_ENV defaulting and removed region defaults, describes local Vercel Queues delivery via registerVercelQueueConsumer(), updates fixture to expose NODE_ENV, and updates tests to expect undefined region envs.

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant registerVercelQueueConsumer
  participant ensureSdk
  participant QueueClient
  participant registerDevConsumer
  Consumer->>registerVercelQueueConsumer: register(topic, handler, retryAfterSeconds?)
  registerVercelQueueConsumer->>registerVercelQueueConsumer: check/replace per-topic slot (HMR-safe)
  alt first registration
    registerVercelQueueConsumer->>ensureSdk: lazy import `@vercel/queue`
    ensureSdk->>QueueClient: construct shared QueueClient
    QueueClient->>registerVercelQueueConsumer: provide client
    registerVercelQueueConsumer->>registerDevConsumer: registerDevConsumer(client, topic, consumerGroup, handler, retry)
  else replacement
    registerVercelQueueConsumer->>registerDevConsumer: replace handler (unregister previous)
  end
  registerVercelQueueConsumer->>Consumer: return unregister closure
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • unjs/env-runner#3: Introduced the initial Vercel runner implementation; this PR extends it with local dev queue handling and runner refinements.

Suggested reviewers

  • pi0

Poem

🐰 I nibble at queues with a curious hop,
handlers swap quick — no server to stop,
lazy imports hum while clients align,
NODE_ENV wakes to development time,
local queues sing and the rabbit does hop!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat(vercel): vercel queues' is vague and does not clearly convey the main change. It mentions 'vercel queues' but lacks specificity about what aspect of queue support is being added (local dev bridge, registration mechanism, etc.). Consider a more descriptive title such as 'feat(vercel): add local dev support for Vercel Queues' or 'feat(vercel): add queue consumer registration bridge' to better clarify the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vercel-queues-local-dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Around line 131-133: Update the AGENTS.md section that claims VERCEL_REGION
and NOW_REGION default to "dev1": these environment variables are no longer set
by the runner (see the comment in src/runners/vercel/worker.ts about SDKs
relying on valid values), so either remove the two lines mentioning
`VERCEL_REGION` and `NOW_REGION` or change them to state they are not defaulted
in local development and must be explicitly set if required; keep the `NODE_ENV`
line as-is and ensure the doc mentions the reason (Vercel SDKs expect valid
values) so readers understand why they must set VERCEL_REGION/NOW_REGION
themselves.

In `@src/runners/vercel/worker.ts`:
- Line 6: Update the coding guideline text that currently mandates setting
VERCEL_REGION and NOW_REGION to "dev1" so it matches the code change that
intentionally leaves those variables unset; specifically modify the guideline
string "Vercel runner worker should set environment variables: `VERCEL=1`,
`VERCEL_ENV=development`, `VERCEL_REGION=dev1`, `NOW_REGION=dev1`,
`NODE_ENV=development`" to remove `VERCEL_REGION=dev1` and `NOW_REGION=dev1`
(leaving `VERCEL=1`, `VERCEL_ENV=development`, `NODE_ENV=development`) or
alternatively clarify that VERCEL_REGION and NOW_REGION must not be defaulted,
ensuring the guidance in src/runners/vercel/worker.ts aligns with the comment
about intentionally not defaulting those env vars.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01373cfe-2738-4e82-ac2b-e95ee27cef2c

📥 Commits

Reviewing files that changed from the base of the PR and between 4b5d42f and 7725733.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • AGENTS.md
  • build.config.mjs
  • package.json
  • src/runners/vercel/queue-dev.ts
  • src/runners/vercel/runner.ts
  • src/runners/vercel/worker.ts

Comment thread AGENTS.md Resolved
Comment thread src/runners/vercel/worker.ts Resolved
@RihanArfan

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@RihanArfan
RihanArfan force-pushed the feat/vercel-queues-local-dev branch from 6a78d92 to 14f92b1 Compare May 19, 2026 12:20
@RihanArfan
RihanArfan requested a review from pi0 May 19, 2026 12:22
Comment thread src/runners/vercel/worker.ts Resolved
Comment thread src/runners/vercel/runner.ts Resolved
Comment thread AGENTS.md
- `VERCEL_ENV` — `"development"`
- `VERCEL_REGION` — `"dev1"`
- `NOW_REGION` — `"dev1"` (legacy alias)
- `NODE_ENV` — `"development"` (gates `@vercel/queue`'s dev mode and other framework dev paths)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be updated once we avoid changing NODE_ENV global modification. (worst case scenario, as a temporary patch we override env during inpuiring vercel/queue sdk and immediately restore)

@pi0 pi0 May 21, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Update: Seems many places use this check, we might upstream something like new QueueClient({ devMode: true }) (added todo)

Comment thread src/runners/vercel/queue-dev.ts Resolved
Comment thread src/runners/vercel/queue-dev.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/runners/vercel/queue-dev.ts`:
- Line 60: The retry configuration currently uses a truthy check so
retryAfterSeconds = 0 is treated as falsy and disables retries; update the
conditional that sets the retry property (the line creating retry:
retryAfterSeconds ? () => ({ afterSeconds: retryAfterSeconds }) : undefined) to
explicitly test for undefined (e.g., retryAfterSeconds !== undefined) so a value
of 0 produces a retry function returning { afterSeconds: retryAfterSeconds }
while undefined still yields undefined.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0e6d81f-daaa-42d2-95dd-3247c25fab1b

📥 Commits

Reviewing files that changed from the base of the PR and between 085947c and 69c6825.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • AGENTS.md
  • package.json
  • src/runners/vercel/queue-dev.ts
  • test/fixtures/app-env.mjs
  • test/vercel.test.ts
✅ Files skipped from review due to trivial changes (1)
  • AGENTS.md

Comment thread src/runners/vercel/queue-dev.ts Resolved
@pi0
pi0 merged commit faa7379 into main May 21, 2026
8 checks passed
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