refactor(*): use async functions (#6210)

This commit is contained in:
Sugden
2021-08-02 00:47:43 +01:00
committed by GitHub
parent 626ff85ae7
commit e2e4f6518b
29 changed files with 298 additions and 399 deletions

View File

@@ -106,7 +106,7 @@ class Shard extends EventEmitter {
* before resolving (`-1` or `Infinity` for no wait)
* @returns {Promise<ChildProcess>}
*/
async spawn(timeout = 30000) {
spawn(timeout = 30000) {
if (this.process) throw new Error('SHARDING_PROCESS_EXISTS', this.id);
if (this.worker) throw new Error('SHARDING_WORKER_EXISTS', this.id);
@@ -137,7 +137,7 @@ class Shard extends EventEmitter {
this.emit('spawn', child);
if (timeout === -1 || timeout === Infinity) return child;
await new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
const cleanup = () => {
clearTimeout(spawnTimeoutTimer);
this.off('ready', onReady);
@@ -147,7 +147,7 @@ class Shard extends EventEmitter {
const onReady = () => {
cleanup();
resolve();
resolve(child);
};
const onDisconnect = () => {
@@ -170,7 +170,6 @@ class Shard extends EventEmitter {
this.once('disconnect', onDisconnect);
this.once('death', onDeath);
});
return child;
}
/**