feat: Lazy-load Push adapter only when Push is configured#10522
Conversation
Skip loading `@parse/push-adapter` and initializing push workers when `options.push` is not set, reducing startup overhead for deployments that don't use Push notifications. Closes parse-community#10518 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesLazy push adapter initialization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Controllers/index.js (1)
185-198: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplification of
hasPushSupportis correct.Since this path only runs when
pushis truthy (guarded by the early return at Line 175), dropping the previous coupling topushand relying solely on!!pushAdapteris equivalent. TheObject.assign({}, push)copy beforedeletealso avoids mutating the caller'soptions.push.Optional: the queue-option extraction can be expressed more idiomatically with rest destructuring.
♻️ Optional: extract queueOptions via destructuring
- const pushOptions = Object.assign({}, push); - const pushQueueOptions = pushOptions.queueOptions || {}; - if (pushOptions.queueOptions) { - delete pushOptions.queueOptions; - } + const { queueOptions: pushQueueOptions = {}, ...pushOptions } = push;🤖 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/Controllers/index.js` around lines 185 - 198, Refactor the push options setup in `Controllers/index.js` to extract `queueOptions` more idiomatically with object rest destructuring instead of cloning `pushOptions` and deleting `queueOptions`. Keep the existing behavior in the `loadModule`, `loadAdapter`, and `PushController` flow unchanged, and ensure `pushOptions` still excludes `queueOptions` while `pushQueueOptions` preserves the extracted value.
🤖 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.
Nitpick comments:
In `@src/Controllers/index.js`:
- Around line 185-198: Refactor the push options setup in `Controllers/index.js`
to extract `queueOptions` more idiomatically with object rest destructuring
instead of cloning `pushOptions` and deleting `queueOptions`. Keep the existing
behavior in the `loadModule`, `loadAdapter`, and `PushController` flow
unchanged, and ensure `pushOptions` still excludes `queueOptions` while
`pushQueueOptions` preserves the extracted value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 79a0488b-9f80-4ff6-83b0-e5f545d3ba2c
📒 Files selected for processing (1)
src/Controllers/index.js
Assert that `@parse/push-adapter` is not loaded when `push` is not configured, and is loaded when `push` is configured. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Issue
Closes #10518 — Parse Server loads the default Push adapter during startup even when Push notifications are not configured, adding unnecessary overhead for serverless, API-only, or test deployments.
Approach
Add an early return in
getPushController()whenoptions.pushis not set. This skips loading the@parse/push-adaptermodule and initializing the push worker entirely, returning sensible defaults (hasPushSupport: false, no worker). Whenpushis configured, existing behavior is fully preserved.Tasks
Summary by CodeRabbit
Bug Fixes
Tests