-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix: ensure the startup is completed before calling startupCompleted
#7525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,38 +82,40 @@ class ParseServer { | |
|
||
logging.setLogger(loggerController); | ||
|
||
if (cloud) { | ||
addParseCloud(); | ||
if (typeof cloud === 'function') { | ||
cloud(Parse); | ||
} else if (typeof cloud === 'string') { | ||
require(path.resolve(process.cwd(), cloud)); | ||
} else { | ||
throw "argument 'cloud' must either be a string or a function"; | ||
} | ||
} | ||
|
||
// Note: Tests will start to fail if any validation happens after this is called. | ||
databaseController | ||
.performInitialization() | ||
.then(() => hooksController.load()) | ||
Promise.resolve() | ||
.then(async () => await databaseController.performInitialization()) | ||
.then(async () => await hooksController.load()) | ||
.then(async () => { | ||
if (schema) { | ||
await new DefinedSchemas(schema, this.config).execute(); | ||
} | ||
}) | ||
.then(async () => { | ||
if (serverStartComplete) { | ||
serverStartComplete(); | ||
await serverStartComplete(); | ||
} | ||
}) | ||
.catch(error => { | ||
.catch(async (error) => { | ||
if (serverStartComplete) { | ||
serverStartComplete(error); | ||
await serverStartComplete(error); | ||
} else { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
}); | ||
Comment on lines
+97
to
117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to help to cross de finish line, here the full correct structure. // Note: Tests will start to fail if any validation happens after this is called.
databaseController.performInitialization()
.then(() => hooksController.load())
.then(async () => {
if (schema) {
await new DefinedSchemas(schema, this.config).execute();
}
})
.then(async () => {
if (serverStartComplete) {
await Promise.resolve(serverStartComplete());
}
})
.catch(async (error) => {
if (serverStartComplete) {
await Promise.resolve(serverStartComplete(error));
} else {
console.error(error);
process.exit(1);
}
}); Then in a futur PR that refactor the start up (BK change) the structure will be try {
await databaseController.performInitialization()
await hooksController.load()
if (schema) {
await new DefinedSchemas(schema, this.config).execute();
}
if (serverStartComplete) {
await Promise.resolve(serverStartComplete());
}
} catch(e){
if (serverStartComplete) {
await Promise.resolve(serverStartComplete(error));
} else {
console.error(error);
process.exit(1);
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmm, not sure what's the difference. I don't remember where, but we had a discussion about starting Promises chains with
I don't think we need to wrap it around |
||
|
||
if (cloud) { | ||
addParseCloud(); | ||
if (typeof cloud === 'function') { | ||
cloud(Parse); | ||
} else if (typeof cloud === 'string') { | ||
require(path.resolve(process.cwd(), cloud)); | ||
} else { | ||
throw "argument 'cloud' must either be a string or a function"; | ||
} | ||
} | ||
|
||
if (security && security.enableCheck && security.enableCheckLog) { | ||
sadortun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
new CheckRunner(options.security).run(); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.