diff --git a/src/index.ts b/src/index.ts index d6dbc51..a801dc4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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>(