presets(vercel): support vercel queues#4306
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR introduces Vercel Queues support to Nitro by defining queue configuration types, implementing a runtime message handler, wiring the handler into the preset, generating queue consumer functions during build, and validating the entire flow with comprehensive tests and documentation. ChangesVercel Queues Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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)
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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/presets/vercel/utils.ts (1)
165-171: ⚡ Quick winMove the new internal helper to the helper section at the end of the module.
warnUnsupportedQueuesis a non-exported helper inserted between exported functions. Please keep newly added internal helpers with the rest of the private utilities at the end of the file.As per coding guidelines, "Place non-exported/internal helpers at the end of the file".
🤖 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/utils.ts` around lines 165 - 171, The helper function warnUnsupportedQueues is a non-exported internal utility and should be relocated to the file's private helper section at the end of the module; move the entire function (including its Nitro parameter and nitro.logger.warn call) out from between exported functions and append it with the other non-exported helpers, keeping the function name and behavior unchanged and updating any nearby ordering comments if present.
🤖 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/utils.ts`:
- Around line 82-98: Validate the normalized handlerRoute before mutating the
filesystem: compute handlerRoute and funcDest using handlerRoute and
normalizeRouteDest (as done currently), then check whether the resolved funcDir
would equal or be inside the source bundle path (nitro.options.output.serverDir)
or otherwise collide (e.g., normalizeRouteDest("/__fallback") -> same
directory); if a collision is detected throw an explicit configuration error
indicating the invalid handlerRoute instead of proceeding to fsp.rm/fsp.cp;
perform this guard prior to any calls to fsp.rm, fsp.mkdir, or fsp.cp so the
source bundle cannot be deleted.
In `@test/unit/vercel.queues.test.ts`:
- Around line 38-51: The suite currently creates a single shared temp outDir in
beforeAll (using outDir and serverDir) which allows leftover .func folders to
leak across tests; change setup to isolate per test by moving the mkdtemp +
serverDir creation and writeFile steps into a beforeEach (or add a beforeEach
that wipes/recreates outDir) and pair it with a corresponding afterEach cleanup
(instead of afterAll) so each it gets a fresh outDir and the temporary functions
(including functions/_vercel/queues/consumer.func) cannot persist between tests;
update references to outDir/serverDir used elsewhere in the file to rely on the
per-test setup.
---
Nitpick comments:
In `@src/presets/vercel/utils.ts`:
- Around line 165-171: The helper function warnUnsupportedQueues is a
non-exported internal utility and should be relocated to the file's private
helper section at the end of the module; move the entire function (including its
Nitro parameter and nitro.logger.warn call) out from between exported functions
and append it with the other non-exported helpers, keeping the function name and
behavior unchanged and updating any nearby ordering comments if present.
🪄 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: 074ffddb-e7d1-49a4-a190-41b5483eb554
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
docs/2.deploy/20.providers/vercel.mdpackage.jsonsrc/presets/vercel/preset.tssrc/presets/vercel/runtime/queue-handler.tssrc/presets/vercel/types.tssrc/presets/vercel/utils.tstest/unit/vercel.queues.test.ts
🔗 Linked issue
Backport of #4127
❓ Type of change
📚 Description
Implements Vercel Queue triggers support within Nitro v2 hooks (and Nuxt v4)
📝 Checklist