Conversation
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds Vercel Queues integration to Nitro, including per-route serverless function configuration via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
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 |
2029791 to
bbe5bf9
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/presets/vercel/runtime/queue-handler.ts (1)
9-11: Remove the unnecessary type castas Request.The
event.reqobject is already aRequestinstance in the Vercel runtime context (as evidenced by cron-handler.ts usingevent.req.headers.get()andevent.req.waitUntilwithout casting). The type cast is redundant and should be removed for consistency with other handlers:return handler(event.req);instead of:
return handler(event.req as Request);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/presets/vercel/runtime/queue-handler.ts` around lines 9 - 11, The return statement in the defineHandler wrapper unnecessarily casts event.req to Request; update the defineHandler callback so it calls handler(event.req) without the redundant "as Request" cast (locate the defineHandler(...) wrapper and the call to handler in queue-handler.ts and remove the type assertion on event.req).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/2.deploy/20.providers/vercel.md`:
- Around line 58-86: The docs incorrectly reference vercel.routeFunctionConfig;
update all occurrences (text and the example in the nitro config) to use
vercel.functionRules so the sample matches the implementation/types;
specifically replace the symbol vercel.routeFunctionConfig with
vercel.functionRules in the example config block and any explanatory text, and
keep the rest of the example keys (e.g., maxDuration, memory, regions,
experimentalTriggers) unchanged.
In `@examples/vercel-queues/package.json`:
- Around line 3-12: The package.json scripts reference Vite ("dev": "vite dev",
"build": "vite build") but Vite is not listed in devDependencies; update the
devDependencies section to include "vite" (e.g., add a "vite": "latest" or
specific version) so the "dev" and "build" scripts resolve reliably alongside
existing entries like "nitro".
In `@src/presets/vercel/utils.ts`:
- Around line 64-69: Typo fix: change "accesible" to "accessible" in the warning
message. Update the string passed to nitro.logger.warn that references
`experimentalTriggers` on `vercel.functions` so the sentence reads "Routes with
queue triggers are not accessible on the web." Keep the rest of the message
intact and ensure references to `vercel.functionRules` remain unchanged.
---
Nitpick comments:
In `@src/presets/vercel/runtime/queue-handler.ts`:
- Around line 9-11: The return statement in the defineHandler wrapper
unnecessarily casts event.req to Request; update the defineHandler callback so
it calls handler(event.req) without the redundant "as Request" cast (locate the
defineHandler(...) wrapper and the call to handler in queue-handler.ts and
remove the type assertion on event.req).
🪄 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: 51894fd6-4700-46c8-8dc2-c7adc93647c3
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (17)
docs/2.deploy/20.providers/vercel.mddocs/4.examples/vercel-queues.mdexamples/vercel-queues/README.mdexamples/vercel-queues/nitro.config.tsexamples/vercel-queues/package.jsonexamples/vercel-queues/plugins/queue.tsexamples/vercel-queues/routes/send.tsexamples/vercel-queues/tasks/notifications/send.tsexamples/vercel-queues/tsconfig.jsonexamples/vercel-queues/vite.config.tspackage.jsonsrc/presets/vercel/preset.tssrc/presets/vercel/runtime/queue-handler.tssrc/presets/vercel/types.tssrc/presets/vercel/utils.tstest/fixture/nitro.config.tstest/presets/vercel.test.ts
| ## Per-route function configuration | ||
|
|
||
| Use `vercel.routeFunctionConfig` to override [serverless function settings](https://vercel.com/docs/build-output-api/primitives#serverless-function-configuration) for specific routes. Each key is a route pattern and its value is a partial function configuration object that gets merged with the base `vercel.functions` config. Note: array properties (e.g., `regions`) from route config will replace the base config arrays rather than merging them. | ||
|
|
||
| This is useful when certain routes need different resource limits, regions, or features like [Vercel Queues triggers](https://vercel.com/docs/queues). | ||
|
|
||
| ```ts [nitro.config.ts] | ||
| import { defineNitroConfig } from "nitro/config"; | ||
|
|
||
| export default defineNitroConfig({ | ||
| vercel: { | ||
| routeFunctionConfig: { | ||
| "/api/heavy-computation": { | ||
| maxDuration: 800, | ||
| memory: 4096, | ||
| }, | ||
| "/api/regional": { | ||
| regions: ["lhr1", "cdg1"], | ||
| }, | ||
| "/api/queues/process-order": { | ||
| experimentalTriggers: [{ type: "queue/v2beta", topic: "orders" }], | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| Route patterns support wildcards via [rou3](https://github.com/h3js/rou3) matching (e.g., `/api/slow/**` matches all routes under `/api/slow/`). | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the actual property name in types
rg -n "routeFunctionConfig|functionRules" src/presets/vercel/types.tsRepository: nitrojs/nitro
Length of output: 152
🏁 Script executed:
# Search for routeFunctionConfig anywhere in the codebase
rg "routeFunctionConfig" --type ts --type js --type md
# Also check the implementation to see what property is actually read
rg -n "functionRules" src/presets/vercel/ -A 2 -B 2Repository: nitrojs/nitro
Length of output: 4432
Documentation uses incorrect property name routeFunctionConfig; should be functionRules.
The documentation references vercel.routeFunctionConfig but the actual TypeScript types and implementation use vercel.functionRules. Users following the documentation will have their configuration silently ignored by the build process.
📝 Suggested fix
-Use `vercel.routeFunctionConfig` to override [serverless function settings](https://vercel.com/docs/build-output-api/primitives#serverless-function-configuration) for specific routes.
+Use `vercel.functionRules` to override [serverless function settings](https://vercel.com/docs/build-output-api/primitives#serverless-function-configuration) for specific routes. vercel: {
- routeFunctionConfig: {
+ functionRules: {
"/api/heavy-computation": {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/2.deploy/20.providers/vercel.md` around lines 58 - 86, The docs
incorrectly reference vercel.routeFunctionConfig; update all occurrences (text
and the example in the nitro config) to use vercel.functionRules so the sample
matches the implementation/types; specifically replace the symbol
vercel.routeFunctionConfig with vercel.functionRules in the example config block
and any explanatory text, and keep the rest of the example keys (e.g.,
maxDuration, memory, regions, experimentalTriggers) unchanged.
| "scripts": { | ||
| "dev": "vite dev", | ||
| "build": "vite build" | ||
| }, | ||
| "dependencies": { | ||
| "@vercel/queue": "latest" | ||
| }, | ||
| "devDependencies": { | ||
| "nitro": "latest" | ||
| } |
There was a problem hiding this comment.
Missing vite dependency.
The scripts use vite dev and vite build, but vite is not declared as a dependency. Add it to devDependencies.
Proposed fix
"devDependencies": {
- "nitro": "latest"
+ "nitro": "latest",
+ "vite": "latest"
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "scripts": { | |
| "dev": "vite dev", | |
| "build": "vite build" | |
| }, | |
| "dependencies": { | |
| "@vercel/queue": "latest" | |
| }, | |
| "devDependencies": { | |
| "nitro": "latest" | |
| } | |
| "scripts": { | |
| "dev": "vite dev", | |
| "build": "vite build" | |
| }, | |
| "dependencies": { | |
| "@vercel/queue": "latest" | |
| }, | |
| "devDependencies": { | |
| "nitro": "latest", | |
| "vite": "latest" | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@examples/vercel-queues/package.json` around lines 3 - 12, The package.json
scripts reference Vite ("dev": "vite dev", "build": "vite build") but Vite is
not listed in devDependencies; update the devDependencies section to include
"vite" (e.g., add a "vite": "latest" or specific version) so the "dev" and
"build" scripts resolve reliably alongside existing entries like "nitro".
| nitro.logger.warn( | ||
| "`experimentalTriggers` on the base `vercel.functions` config applies to the catch-all function and is likely not what you want. " + | ||
| "Routes with queue triggers are not accesible on the web." + | ||
| "Use `vercel.functionRules` to attach triggers to specific routes instead." | ||
| ); | ||
| } |
There was a problem hiding this comment.
Typo: "accesible" should be "accessible".
📝 Fix
nitro.logger.warn(
"`experimentalTriggers` on the base `vercel.functions` config applies to the catch-all function and is likely not what you want. " +
- "Routes with queue triggers are not accesible on the web." +
+ "Routes with queue triggers are not accessible on the web. " +
"Use `vercel.functionRules` to attach triggers to specific routes instead."
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| nitro.logger.warn( | |
| "`experimentalTriggers` on the base `vercel.functions` config applies to the catch-all function and is likely not what you want. " + | |
| "Routes with queue triggers are not accesible on the web." + | |
| "Use `vercel.functionRules` to attach triggers to specific routes instead." | |
| ); | |
| } | |
| nitro.logger.warn( | |
| "`experimentalTriggers` on the base `vercel.functions` config applies to the catch-all function and is likely not what you want. " + | |
| "Routes with queue triggers are not accessible on the web. " + | |
| "Use `vercel.functionRules` to attach triggers to specific routes instead." | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/presets/vercel/utils.ts` around lines 64 - 69, Typo fix: change
"accesible" to "accessible" in the warning message. Update the string passed to
nitro.logger.warn that references `experimentalTriggers` on `vercel.functions`
so the sentence reads "Routes with queue triggers are not accessible on the
web." Keep the rest of the message intact and ensure references to
`vercel.functionRules` remain unchanged.
Warning
Waiting on #4124
🔗 Linked issue
Related #1974
❓ Type of change
📚 Description
Support Vercel Queues triggers through Nitro hooks, and documents using it with Nitro Tasks.
📝 Checklist