From aefd401d22f17994bdcd017f003524ce1a0dab0c Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 6 Apr 2023 10:29:59 -0400 Subject: [PATCH] *Create a setup defer to ensure we wait until the 1st sync is done before setting up the stream on our end --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 6005136..d6dbc51 100644 --- a/src/index.ts +++ b/src/index.ts @@ -202,6 +202,7 @@ export class Socket extends Client { this.swarm.emit("setup", this); let updateDone = defer(); + const setup = defer(); const [update] = this.connectModule( "syncProtomux", @@ -238,6 +239,7 @@ export class Socket extends Client { update(true); this.syncMutex.release(); + setup.resolve(); } ); @@ -250,6 +252,7 @@ export class Socket extends Client { await updateDone.promise; }; mux.syncState = send.bind(undefined, mux); + return setup.promise; } on>(