New Issue Checklist
Issue Description
If the Parse Server option masterKey is set to a function, the function is supposed to be called when Parse Server starts; ParseServer.start() in src/ParseServer.ts adds this.config.loadMasterKey?.() to the startup tasks. However, this.config is the plain options object returned by Config.put(), not a Config instance. It has no loadMasterKey method, so the optional call does nothing. This has been the case since setting masterKey to a function was added in #9582 (Parse Server 8.0.0).
As a result, the function is only called on the first request. If it fails, for example because a secret store is unavailable, Parse Server starts nonetheless and responds to every request with status 500, including the /health endpoint. Other startup tasks, such as the migration of the schema option or the connection of the cache adapter, make the start fail instead.
Steps to reproduce
- Start Parse Server with
masterKey: () => Promise.reject(new Error('secret store unavailable')), and await ParseServer.start().
- Send any request, for example
GET /parse/health.
Actual Outcome
ParseServer.start() resolves; the masterKey function has not been called. The request fails with status 500 and {"code":1,"message":"Internal server error."}, and so does every following request.
Expected Outcome
The masterKey function is called when Parse Server starts, and ParseServer.start() rejects if the function fails.
Environment
Server
- Parse Server version:
9.10.2-alpha.4 (alpha branch); since 8.0.0
- Operating system: any
- Local or remote host: any
Database
- System: any
- Database version: any
- Local or remote host: any
Client
- SDK: any
- SDK version: any
Logs
Not applicable
New Issue Checklist
Issue Description
If the Parse Server option
masterKeyis set to a function, the function is supposed to be called when Parse Server starts;ParseServer.start()insrc/ParseServer.tsaddsthis.config.loadMasterKey?.()to the startup tasks. However,this.configis the plain options object returned byConfig.put(), not aConfiginstance. It has noloadMasterKeymethod, so the optional call does nothing. This has been the case since settingmasterKeyto a function was added in #9582 (Parse Server 8.0.0).As a result, the function is only called on the first request. If it fails, for example because a secret store is unavailable, Parse Server starts nonetheless and responds to every request with status 500, including the
/healthendpoint. Other startup tasks, such as the migration of theschemaoption or the connection of the cache adapter, make the start fail instead.Steps to reproduce
masterKey: () => Promise.reject(new Error('secret store unavailable')), and awaitParseServer.start().GET /parse/health.Actual Outcome
ParseServer.start()resolves; themasterKeyfunction has not been called. The request fails with status 500 and{"code":1,"message":"Internal server error."}, and so does every following request.Expected Outcome
The
masterKeyfunction is called when Parse Server starts, andParseServer.start()rejects if the function fails.Environment
Server
9.10.2-alpha.4(alphabranch); since8.0.0Database
Client
Logs
Not applicable