From 0596a132f3f9c0cbb5c415870fbe111440c44f10 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 6 Apr 2023 10:48:27 -0400 Subject: [PATCH] *Move setup emit until after the setup promise has resolved --- src/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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>(