Skip to content

Commit 4ca73f6

Browse files
committed
Ensure the startup is completed before calling startupCompleted
1 parent 2783245 commit 4ca73f6

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/ParseServer.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,22 @@ 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())
86+
.then(async () => await hooksController.load())
8787
.then(() => {
88+
if (cloud) {
89+
addParseCloud();
90+
if (typeof cloud === 'function') {
91+
cloud(Parse);
92+
} else if (typeof cloud === 'string') {
93+
require(path.resolve(process.cwd(), cloud));
94+
} else {
95+
throw "argument 'cloud' must either be a string or a function";
96+
}
97+
}
98+
})
99+
.then(async () => {
88100
if (serverStartComplete) {
89-
serverStartComplete();
101+
await serverStartComplete();
90102
}
91103
})
92104
.catch(error => {
@@ -98,17 +110,6 @@ class ParseServer {
98110
}
99111
});
100112

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-
112113
if (security && security.enableCheck && security.enableCheckLog) {
113114
new CheckRunner(options.security).run();
114115
}

0 commit comments

Comments
 (0)