*Create a setup defer to ensure we wait until the 1st sync is done before setting up the stream on our end

This commit is contained in:
Derrick Hammer 2023-04-06 10:29:59 -04:00
parent 650998c810
commit aefd401d22
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 0 deletions

View File

@ -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<T extends EventEmitter.EventNames<string | symbol>>(