From 655220cf6f78053d7d82cf8df428bdc5fa358f51 Mon Sep 17 00:00:00 2001 From: ga262 <37159881+ga262@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:46:17 +0200 Subject: [PATCH 1/2] feat: Lazy-load Push adapter only when Push is configured 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 #10518 Co-Authored-By: Claude Sonnet 4.6 --- src/Controllers/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Controllers/index.js b/src/Controllers/index.js index 9397dac561..784e431aaa 100644 --- a/src/Controllers/index.js +++ b/src/Controllers/index.js @@ -172,23 +172,30 @@ interface PushControlling { export async function getPushController(options: ParseServerOptions): PushControlling { const { scheduledPush, push } = options; + if (!push) { + return { + pushController: new PushController(), + hasPushSupport: false, + hasPushScheduledSupport: false, + pushControllerQueue: new PushQueue(), + pushWorker: undefined, + }; + } + const pushOptions = Object.assign({}, push); const pushQueueOptions = pushOptions.queueOptions || {}; if (pushOptions.queueOptions) { delete pushOptions.queueOptions; } - // Pass the push options too as it works with the default const ParsePushAdapter = await loadModule('@parse/push-adapter'); const pushAdapter = loadAdapter( pushOptions && pushOptions.adapter, ParsePushAdapter, pushOptions ); - // We pass the options and the base class for the adatper, - // Note that passing an instance would work too const pushController = new PushController(); - const hasPushSupport = !!(pushAdapter && push); + const hasPushSupport = !!pushAdapter; const hasPushScheduledSupport = hasPushSupport && scheduledPush === true; const { disablePushWorker } = pushQueueOptions; From 16a28addcbdb27f0608a21472666eff421623b60 Mon Sep 17 00:00:00 2001 From: ga262 <37159881+ga262@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:09:05 +0200 Subject: [PATCH 2/2] test: Add coverage for lazy-loading Push adapter only when configured 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 --- spec/index.spec.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec/index.spec.js b/spec/index.spec.js index 988f35cc3e..012b17a191 100644 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -211,6 +211,34 @@ describe('server', () => { .catch(done.fail); }); + it('does not load the push adapter when push is not configured', async () => { + const Controllers = require('../lib/Controllers'); + const AdapterLoader = require('../lib/Adapters/AdapterLoader'); + const loadModule = spyOn(AdapterLoader, 'loadModule').and.callThrough(); + const result = await Controllers.getPushController({ push: undefined }); + expect(loadModule).not.toHaveBeenCalled(); + expect(result.hasPushSupport).toBe(false); + expect(result.hasPushScheduledSupport).toBe(false); + expect(result.pushWorker).toBeUndefined(); + }); + + it('loads the push adapter when push is configured', async () => { + const Controllers = require('../lib/Controllers'); + const AdapterLoader = require('../lib/Adapters/AdapterLoader'); + const loadModule = spyOn(AdapterLoader, 'loadModule').and.callThrough(); + const result = await Controllers.getPushController({ + push: { + adapter: { + send() {}, + getValidPushTypes() {}, + }, + queueOptions: { disablePushWorker: true }, + }, + }); + expect(loadModule).toHaveBeenCalledWith('@parse/push-adapter'); + expect(result.hasPushSupport).toBe(true); + }); + it('can properly sets the push support ', done => { reconfigureServer({ push: {