diff --git a/packages/programs/data/shared-log/src/index.ts b/packages/programs/data/shared-log/src/index.ts index b091a8c05..07db0e49f 100644 --- a/packages/programs/data/shared-log/src/index.ts +++ b/packages/programs/data/shared-log/src/index.ts @@ -168,16 +168,19 @@ export class SharedLog extends Program< this.role, this.node.identity.publicKey ); - if (!this._loadedOnce) { - await this.log.load(); - this._loadedOnce = true; - } - await this.rpc.subscribe(); - await this.rpc.send(new ResponseRoleMessage(role)); + if (!this.closed) { + if (!this._loadedOnce) { + await this.log.load(); + this._loadedOnce = true; + } + await this.rpc.subscribe(); + await this.rpc.send(new ResponseRoleMessage(role)); - if (onRoleChange) { - this.onRoleChange(undefined, this._role, this.node.identity.publicKey); + if (onRoleChange) { + this.onRoleChange(undefined, this._role, this.node.identity.publicKey); + } } + return changed; }