Skip to content

Commit 0d30231

Browse files
committed
Ensure the startup is completed before calling startupCompleted
1 parent 4a0b4eb commit 0d30231

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/ParseServer.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,27 @@ class ParseServer {
8383
// Note: Tests will start to fail if any validation happens after this is called.
8484
databaseController
8585
.performInitialization()
86-
.then(() => hooksController.load())
87-
.then(() => {
86+
.then(async () => await hooksController.load())
87+
.then(async () => {
8888
if (serverStartComplete) {
89-
serverStartComplete();
89+
await serverStartComplete();
90+
}
91+
})
92+
.then(() => {
93+
if (cloud) {
94+
addParseCloud();
95+
if (typeof cloud === 'function') {
96+
cloud(Parse);
97+
} else if (typeof cloud === 'string') {
98+
require(path.resolve(process.cwd(), cloud));
99+
} else {
100+
throw "argument 'cloud' must either be a string or a function";
101+
}
102+
}
103+
})
104+
.then(() => {
105+
if (security && security.enableCheck && security.enableCheckLog) {
106+
new CheckRunner(options.security).run();
90107
}
91108
})
92109
.catch(error => {
@@ -97,21 +114,6 @@ class ParseServer {
97114
process.exit(1);
98115
}
99116
});
100-
101-
if (cloud) {
102-
addParseCloud();
103-
if (typeof cloud === 'function') {
104-
cloud(Parse);
105-
} else if (typeof cloud === 'string') {
106-
require(path.resolve(process.cwd(), cloud));
107-
} else {
108-
throw "argument 'cloud' must either be a string or a function";
109-
}
110-
}
111-
112-
if (security && security.enableCheck && security.enableCheckLog) {
113-
new CheckRunner(options.security).run();
114-
}
115117
}
116118

117119
get app() {

0 commit comments

Comments
 (0)