Skip to content

fix: Allow Parse Server startup without optional push adapter#10446

Open
ga262 wants to merge 3 commits intoparse-community:alphafrom
ga262:fix/optional-push-adapter
Open

fix: Allow Parse Server startup without optional push adapter#10446
ga262 wants to merge 3 commits intoparse-community:alphafrom
ga262:fix/optional-push-adapter

Conversation

@ga262
Copy link
Copy Markdown

@ga262 ga262 commented Apr 21, 2026

Issue

Parse Server currently declares @parse/push-adapter as an optional dependency, but startup still attempts to load it unconditionally in the push controller path. This creates a mismatch between package metadata and runtime behavior.

Current behavior

  • If @parse/push-adapter is not installed:
    • startup may fail due to default push adapter import
    • this can happen even when push is not explicitly configured
  • If push is configured without a custom push.adapter, startup fails with a generic module resolution error

Expected behavior

  • When push is not configured, Parse Server should start even if @parse/push-adapter is absent
  • When push is configured but no custom adapter is provided, Parse Server should fail with a clear actionable error indicating that @parse/push-adapter must be installed (or push.adapter must be provided)

Why this matters

  • aligns runtime behavior with optionalDependencies intent
  • avoids forcing optional push dependencies in deployments that do not use push notifications
  • improves DX for minimal/containerized installs (e.g. --omit=optional)
  • preserves explicit failure when push is actually requested but misconfigured

Summary

  • handle missing @parse/push-adapter when loading the default push adapter
  • allow server startup when push is not configured and the optional adapter is not installed
  • throw a clear startup error when push is configured but neither @parse/push-adapter nor a custom push.adapter is available
  • only create PushWorker when push support is enabled

Test plan

  • npm run build
  • npm run testonly spec/index.spec.js
  • npm run testonly spec/AdapterLoader.spec.js
  • added test: startup succeeds when push is undefined and @parse/push-adapter is missing
  • added test: startup fails with explicit error when push is configured and @parse/push-adapter is missing

Summary by CodeRabbit

Release Notes

  • New Features

    • Push adapter is now optional—only installed when explicitly needed, reducing default installation footprint.
  • Improvements

    • Clearer error messages when push functionality is configured but its adapter is not installed.
    • Push worker initialization now conditional on push support availability.

ga262 added 3 commits April 21, 2026 16:29
Signed-off-by: ga262 <37159881+ga262@users.noreply.github.com>
Added a function to check for missing push adapter module and handle errors accordingly.

Signed-off-by: ga262 <37159881+ga262@users.noreply.github.com>
Removed '@parse/push-adapter' from dependencies and added it to optionalDependencies.

Signed-off-by: ga262 <37159881+ga262@users.noreply.github.com>
@parse-github-assistant
Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title fix: allow Parse Server startup without optional push adapter fix: Allow Parse Server startup without optional push adapter Apr 21, 2026
@parse-github-assistant
Copy link
Copy Markdown

parse-github-assistant Bot commented Apr 21, 2026

🚀 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

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

This change converts @parse/push-adapter from a required dependency to an optional one, adds error detection for missing module scenarios, and implements graceful degradation with improved error messaging. The push worker is now conditionally created only when push support is available.

Changes

Cohort / File(s) Summary
Dependency Migration
package.json
Moved @parse/push-adapter from dependencies to optionalDependencies at version 8.4.0, making it conditionally installable.
Error Handling & Logic
src/Controllers/index.js
Added isPushAdapterModuleMissing() helper to detect missing module errors; wrapped loadModule() in try/catch to rethrow unrelated errors but throw clearer config error when adapter is missing and push is configured; changed worker creation to only instantiate PushWorker when both disablePushWorker is false and hasPushSupport is true.
Test Coverage
spec/index.spec.js
Added two test cases: one verifies hasPushSupport becomes false when adapter is missing and push is undefined; another verifies reconfigureServer rejects with a specific error message indicating the missing optional dependency when push is configured but adapter is unavailable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Engage In Review Feedback ❓ Inconclusive Cannot verify engagement with review feedback without access to GitHub PR discussion interface, reviewer comments, and author responses. Provide evidence from GitHub PR interface including reviewer comments, author responses, review cycles, or confirmation that PR is awaiting initial feedback.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title begins with the required 'fix:' prefix and clearly summarizes the main change: allowing Parse Server startup without the optional push adapter.
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.
Security Check ✅ Passed Pull request properly handles optional @parse/push-adapter dependency with secure error handling patterns, no code injection or prototype pollution vulnerabilities detected.
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering issue details, approach, expected behavior, and a clear test plan with checkmarks indicating completed tasks.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Controllers/index.js (1)

172-201: ⚠️ Potential issue | 🟠 Major

Only load the default push adapter when it is actually needed.

Line 191 unconditionally imports the optional default adapter even when push is unset or a custom push.adapter is provided. This can cause startup to fail unnecessarily when the adapter is not used. Additionally, the error detection at line 176 using message.includes('@parse/push-adapter') can misclassify transitive dependency failures from within @parse/push-adapter as a missing package if the error message path happens to contain that string.

Move the import into the conditional block that only executes when actually needed:

Suggested fix
 function isPushAdapterModuleMissing(error: any): boolean {
   const message = `${error?.message || error || ''}`;
   const hasMissingCode =
     error?.code === 'ERR_MODULE_NOT_FOUND' || error?.code === 'MODULE_NOT_FOUND';
-  return hasMissingCode && message.includes('@parse/push-adapter');
+  return (
+    hasMissingCode &&
+    /Cannot find (?:package|module) ['"]@parse\/push-adapter['"]/.test(message)
+  );
 }
 
   // Pass the push options too as it works with the default
   let ParsePushAdapter;
-  try {
-    ParsePushAdapter = await loadModule('@parse/push-adapter');
-  } catch (error) {
-    if (!isPushAdapterModuleMissing(error)) {
-      throw error;
-    }
-    if (push && !pushOptions.adapter) {
+  if (push && !pushOptions.adapter) {
+    try {
+      ParsePushAdapter = await loadModule('@parse/push-adapter');
+    } catch (error) {
+      if (!isPushAdapterModuleMissing(error)) {
+        throw error;
+      }
       throw new Error(
         'Push is configured but the optional dependency "@parse/push-adapter" is not installed. Install "@parse/push-adapter" or configure "push.adapter".'
       );
     }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Controllers/index.js` around lines 172 - 201, The code currently calls
loadModule('@parse/push-adapter') unconditionally and uses
isPushAdapterModuleMissing(error) which naively checks
message.includes('@parse/push-adapter'), causing unnecessary startup failures
and false positives; update getPushController so ParsePushAdapter is only loaded
when push is truthy and pushOptions.adapter is not provided (i.e. move the await
loadModule('@parse/push-adapter') call inside the conditional that checks if
push && !pushOptions.adapter), and harden isPushAdapterModuleMissing(error) to
detect a missing package more precisely by checking error.code for
'ERR_MODULE_NOT_FOUND' or 'MODULE_NOT_FOUND' and matching the error message
against a stricter pattern that looks for "Cannot find module" (or the module
name quoted) specifically for '@parse/push-adapter' rather than a simple
substring match.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/Controllers/index.js`:
- Around line 172-201: The code currently calls
loadModule('@parse/push-adapter') unconditionally and uses
isPushAdapterModuleMissing(error) which naively checks
message.includes('@parse/push-adapter'), causing unnecessary startup failures
and false positives; update getPushController so ParsePushAdapter is only loaded
when push is truthy and pushOptions.adapter is not provided (i.e. move the await
loadModule('@parse/push-adapter') call inside the conditional that checks if
push && !pushOptions.adapter), and harden isPushAdapterModuleMissing(error) to
detect a missing package more precisely by checking error.code for
'ERR_MODULE_NOT_FOUND' or 'MODULE_NOT_FOUND' and matching the error message
against a stricter pattern that looks for "Cannot find module" (or the module
name quoted) specifically for '@parse/push-adapter' rather than a simple
substring match.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 950bd482-0f92-4d9f-b1b7-633395bf13d3

📥 Commits

Reviewing files that changed from the base of the PR and between 0980ab1 and 7954250.

📒 Files selected for processing (3)
  • package.json
  • spec/index.spec.js
  • src/Controllers/index.js

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.

1 participant