feat(vercel): support queues in local dev#4264
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds local development for Vercel Queues: new ChangesVercel Queues Local Development
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/presets/vercel/runtime/queue.dev.ts (1)
50-53: ⚡ Quick winAvoid silent teardown failures in
closehookThe empty
catchhides unregister failures, making local queue teardown issues hard to diagnose. Log/capture the error instead of swallowing it.Suggested diff
nitroApp.hooks.hook("close", () => { for (const unregister of unregisters) { try { unregister(); - } catch {} + } catch (error) { + nitroApp.captureError?.(error as Error, { + tags: ["vercel:queue", "close"], + }); + } } });🤖 Prompt for 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. In `@src/presets/vercel/runtime/queue.dev.ts` around lines 50 - 53, The close hook currently swallows errors from unregister() with an empty catch; update the catch to capture the exception and log it (e.g., catch (err) { console.error('Failed to unregister local queue in close hook:', err) } or use an existing logger like processLogger.error) so failures in unregister() are visible; keep the call to unregister() and ensure the log includes context and the error object for debugging.
🤖 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/presets/vercel/runtime/queue.dev.ts`:
- Line 36: Replace the direct console.error call in queue.dev.ts with the
preset/dev logger: use nitroApp.logger.error(...) if a nitroApp instance is in
scope, otherwise import and use consola.error(...); specifically change the
console.error("[vercel:queue]", error) invocation to call the appropriate
logger, and add the required import or ensure nitroApp is available in the
surrounding function where the error is handled.
- Line 5: The import path and symbol are wrong: replace the import of
registerVercelQueueConsumer from "env-runner/runners/vercel/queue-dev" with the
correct export from "env-runner/runners/vercel" (verify the exact exported
function name in that package and update the import to match), update any
references to registerVercelQueueConsumer if the exported name differs, change
the console.error call at the place currently using console.error to
consola.error, and inside the teardown catch block (the empty catch around
teardown logic) add explicit error handling/logging (e.g., log the error via
consola.error with context) so errors are not silently swallowed.
---
Nitpick comments:
In `@src/presets/vercel/runtime/queue.dev.ts`:
- Around line 50-53: The close hook currently swallows errors from unregister()
with an empty catch; update the catch to capture the exception and log it (e.g.,
catch (err) { console.error('Failed to unregister local queue in close hook:',
err) } or use an existing logger like processLogger.error) so failures in
unregister() are visible; keep the call to unregister() and ensure the log
includes context and the error object for debugging.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9ccb08c1-7a29-4496-bf7c-d75f658bd36e
📒 Files selected for processing (5)
docs/2.deploy/20.providers/vercel.mdsrc/presets/_types.gen.tssrc/presets/vercel/dev.tssrc/presets/vercel/preset.tssrc/presets/vercel/runtime/queue.dev.ts
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
src/presets/vercel/runtime/queue.dev.ts (2)
36-36:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUse Nitro/consola logger instead of
console.error.Line [36] and Line [51] should use
nitroApp.logger(orconsola) for preset/dev logging consistency.Suggested diff
- console.error("[vercel:queue]", error); + nitroApp.logger.error("[vercel:queue]", error); ... - console.error("[vercel:queue] failed to register dev consumer:", error); + nitroApp.logger.error("[vercel:queue] failed to register dev consumer:", error);As per coding guidelines
src/{build,dev,cli,presets}/**/*.{ts,js,mjs}: Useconsolafor logging in build/dev code, ornitro.loggerwhen available.Also applies to: 50-52
🤖 Prompt for 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. In `@src/presets/vercel/runtime/queue.dev.ts` at line 36, Replace direct console.error calls in the dev preset with the project logger: use nitroApp.logger.error (if nitroApp is in scope) or import and use consola.error to keep logging consistent; update the error calls in the file (the console.error at the error-handling site and the similar call around lines 50–52) to call the logger instead, ensuring the same error object/message is passed through and adding an appropriate prefix like "[vercel:queue]" if needed.
54-59:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winDon’t silently swallow unregister failures on shutdown.
Line [58] has an empty
catch {}; this hides teardown problems and makes retry/debug behavior opaque.Suggested diff
nitroApp.hooks.hook("close", () => { for (const unregister of unregisters) { try { unregister(); - } catch {} + } catch (error) { + nitroApp.logger.error("[vercel:queue] failed to unregister dev consumer:", error); + } } });🤖 Prompt for 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. In `@src/presets/vercel/runtime/queue.dev.ts` around lines 54 - 59, The shutdown hook registered via nitroApp.hooks.hook("close", ...) currently swallows exceptions from each unregister() call (the empty catch {}); modify the handler to catch errors from each unregister(), log the error (including the unregister identifier/context if available) via the existing logger or console.error, and optionally continue to attempt remaining unregisters; ensure the catch block at least records the exception (e.g., with processLogger.error or console.error) rather than being empty so teardown failures are visible and debuggable.
🤖 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/presets/vercel/runtime/queue.dev.ts`:
- Around line 44-46: The Promise.then callback currently uses an
implicitly-typed parameter `unregister`; update its signature to the explicit
type matching the `unregisters` array element type declared earlier (the same
type used at its declaration on line 22) so TypeScript strict mode compiles;
also replace any console.error calls in this file (including the ones at the
sites around the .then and at line 51) with the proyecto-wide logger
`consola.error` (ensure `consola` is imported), and remove the empty catch block
at the cleanup section by logging the caught error with `consola.error` (include
contextual message) so cleanup failures are not swallowed.
---
Duplicate comments:
In `@src/presets/vercel/runtime/queue.dev.ts`:
- Line 36: Replace direct console.error calls in the dev preset with the project
logger: use nitroApp.logger.error (if nitroApp is in scope) or import and use
consola.error to keep logging consistent; update the error calls in the file
(the console.error at the error-handling site and the similar call around lines
50–52) to call the logger instead, ensuring the same error object/message is
passed through and adding an appropriate prefix like "[vercel:queue]" if needed.
- Around line 54-59: The shutdown hook registered via
nitroApp.hooks.hook("close", ...) currently swallows exceptions from each
unregister() call (the empty catch {}); modify the handler to catch errors from
each unregister(), log the error (including the unregister identifier/context if
available) via the existing logger or console.error, and optionally continue to
attempt remaining unregisters; ensure the catch block at least records the
exception (e.g., with processLogger.error or console.error) rather than being
empty so teardown failures are visible and debuggable.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5d2bba4f-a559-479d-9408-abb3b8075007
📒 Files selected for processing (1)
src/presets/vercel/runtime/queue.dev.ts
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
♻️ Duplicate comments (4)
src/presets/vercel/runtime/queue.dev.ts (4)
38-38: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winReplace
console.errorwithconsolaornitroApp.logger.Both
console.errorcalls violate the coding guideline for this file path. As per coding guidelines:src/{build,dev,cli,presets}/**/*.{ts,js,mjs}: Useconsolafor logging in build/dev code, ornitro.loggerwhen available.♻️ Proposed fix
Import consola at the top of the file:
+import consola from "consola"; import { send } from "`@vercel/queue`";Then replace both console.error calls:
- console.error("[vercel:queue]", error); + consola.error("[vercel:queue]", error);- console.error("[vercel:queue] failed to register dev consumer:", error); + consola.error("[vercel:queue] failed to register dev consumer:", error);Alternatively, use
nitroApp.logger.error()sincenitroAppis already in scope.Also applies to: 51-51
🤖 Prompt for 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. In `@src/presets/vercel/runtime/queue.dev.ts` at line 38, Replace the direct console.error calls in queue.dev.ts (the calls that log "[vercel:queue]" errors) with the project logger: either import and use consola and call consola.error(...) or call nitroApp.logger.error(...) since nitroApp is in scope; update both occurrences (around the "[vercel:queue]" error logs) and remove the console.error usage to comply with src/{build,dev,cli,presets} logging guidelines.
46-47:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winAdd explicit type annotation to fix strict TypeScript error.
The
unregisterparameter has an implicitanytype, which fails strict TypeScript compilation. Add an explicit type annotation to match theunregistersarray type.🔧 Proposed fix
- }).then((unregister) => { + }).then((unregister: () => void) => { unregisters.push(unregister); })🤖 Prompt for 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. In `@src/presets/vercel/runtime/queue.dev.ts` around lines 46 - 47, The then-callback parameter "unregister" has an implicit any; annotate it explicitly to match the element type of the existing "unregisters" array: change the callback signature in the .then(...) on the Promise to use (unregister: typeof unregisters[number]) => { ... } so the parameter type aligns with the unregisters array element type (ensuring strict TypeScript compiles) while keeping the body that pushes the value into unregisters unchanged.
56-60:⚠️ Potential issue | 🟠 Major | ⚡ Quick winLog cleanup errors instead of silently swallowing them.
The empty catch block hides unregistration failures, making debugging difficult. Add error logging to track cleanup issues.
🛡️ Proposed fix
for (const unregister of unregisters) { try { unregister(); - } catch {} + } catch (error) { + consola.error("[vercel:queue] failed to unregister consumer:", error); + } }🤖 Prompt for 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. In `@src/presets/vercel/runtime/queue.dev.ts` around lines 56 - 60, The current cleanup loop silently swallows exceptions when calling each unregister function (for (const unregister of unregisters) { try { unregister(); } catch {} }), which hides failures; update the catch to log the error instead of leaving it empty—use the existing logger (or processLogger) to call error with a descriptive message and include the caught error and some context (e.g., which unregister or index) so unregistration failures are visible during teardown; ensure the catch handles both Error objects and unknown throwables when referencing unregister/unregisters for context.
3-3:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winCritical: Verify the import path and function availability.
The import
env-runner/runners/vercel/queue-devfails with a module-not-found error. Since this PR is blocked by env-runner PR#16, either that change hasn't been published in version 0.1.9, or the import path is incorrect.Verify the correct import path and function export:
#!/bin/bash # Description: Verify env-runner exports and version echo "=== Check installed env-runner version ===" npm list env-runner 2>/dev/null || echo "Not found in package-lock" echo -e "\n=== Check env-runner package.json for exports ===" cat node_modules/env-runner/package.json 2>/dev/null | jq '.version, .exports' || echo "node_modules not available" echo -e "\n=== Search for queue-dev or registerVercelQueueConsumer in env-runner ===" fd -e ts -e mts -e js -e mjs . node_modules/env-runner 2>/dev/null | xargs rg -l "registerVercelQueueConsumer|queue-dev" || echo "Not found" echo -e "\n=== Check what's actually exported from vercel runner ===" cat node_modules/env-runner/dist/runners/vercel/index.d.ts 2>/dev/null || cat node_modules/env-runner/runners/vercel/index.d.ts 2>/dev/null || echo "Type definitions not found"Additionally, search for the latest env-runner documentation:
env-runner package version 0.1.9 registerVercelQueueConsumer queue-dev export🤖 Prompt for 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. In `@src/presets/vercel/runtime/queue.dev.ts` at line 3, The import of registerVercelQueueConsumer from env-runner/runners/vercel/queue-dev is failing; inspect the installed env-runner package version and its exports, search node_modules for symbols registerVercelQueueConsumer and queue-dev (or similar names) to find the correct module path or exported name, then update the import in src/presets/vercel/runtime/queue.dev.ts to match the actual exported symbol/path (or switch to the correct named export such as whatever is found under the vercel runner index), and if the API is not yet published pin or update the dependency to the version that contains the export or add a guarded fallback to avoid the module-not-found error.
🤖 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.
Duplicate comments:
In `@src/presets/vercel/runtime/queue.dev.ts`:
- Line 38: Replace the direct console.error calls in queue.dev.ts (the calls
that log "[vercel:queue]" errors) with the project logger: either import and use
consola and call consola.error(...) or call nitroApp.logger.error(...) since
nitroApp is in scope; update both occurrences (around the "[vercel:queue]" error
logs) and remove the console.error usage to comply with
src/{build,dev,cli,presets} logging guidelines.
- Around line 46-47: The then-callback parameter "unregister" has an implicit
any; annotate it explicitly to match the element type of the existing
"unregisters" array: change the callback signature in the .then(...) on the
Promise to use (unregister: typeof unregisters[number]) => { ... } so the
parameter type aligns with the unregisters array element type (ensuring strict
TypeScript compiles) while keeping the body that pushes the value into
unregisters unchanged.
- Around line 56-60: The current cleanup loop silently swallows exceptions when
calling each unregister function (for (const unregister of unregisters) { try {
unregister(); } catch {} }), which hides failures; update the catch to log the
error instead of leaving it empty—use the existing logger (or processLogger) to
call error with a descriptive message and include the caught error and some
context (e.g., which unregister or index) so unregistration failures are visible
during teardown; ensure the catch handles both Error objects and unknown
throwables when referencing unregister/unregisters for context.
- Line 3: The import of registerVercelQueueConsumer from
env-runner/runners/vercel/queue-dev is failing; inspect the installed env-runner
package version and its exports, search node_modules for symbols
registerVercelQueueConsumer and queue-dev (or similar names) to find the correct
module path or exported name, then update the import in
src/presets/vercel/runtime/queue.dev.ts to match the actual exported symbol/path
(or switch to the correct named export such as whatever is found under the
vercel runner index), and if the API is not yet published pin or update the
dependency to the version that contains the export or add a guarded fallback to
avoid the module-not-found error.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 591fa55a-0c9a-4356-a661-a4a4ce02eeec
📒 Files selected for processing (1)
src/presets/vercel/runtime/queue.dev.ts
🔗 Linked issue
#4127
Blocked by unjs/env-runner#16
❓ Type of change
📚 Description
Support Vercel Queues during local development. Calling
send()from@vercel/queuewill call the consumers registered withinnitro.config.ts.Also introduces usage of Vercel env-runner preset during dev when Vercel preset is set.
📝 Checklist