*Move setup emit until after the setup promise has resolved

This commit is contained in:
Derrick Hammer 2023-04-06 10:48:27 -04:00
parent f5127bd809
commit 0596a132f3
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 3 deletions

View File

@ -199,8 +199,6 @@ export class Socket extends Client {
this.userData = null;
const mux = Protomux.from(this);
this.swarm.emit("setup", this);
let updateDone = defer();
const setup = defer();
@ -252,7 +250,8 @@ export class Socket extends Client {
await updateDone.promise;
};
mux.syncState = send.bind(undefined, mux);
return setup.promise;
await setup.promise;
this.swarm.emit("setup", this);
}
on<T extends EventEmitter.EventNames<string | symbol>>(