diff --git a/packages/programs/data/shared-log/src/index.ts b/packages/programs/data/shared-log/src/index.ts index 6549b9c1e..af5643f24 100644 --- a/packages/programs/data/shared-log/src/index.ts +++ b/packages/programs/data/shared-log/src/index.ts @@ -997,6 +997,8 @@ export class SharedLog< key: PublicSignKey | string, options?: { noEvent?: boolean }, ) { + if (this.closed) return; + const keyHash = typeof key === "string" ? key : key.hashcode(); const deleted = await this.replicationIndex .iterate({ @@ -3673,6 +3675,11 @@ export class SharedLog< replicas: number; prev?: EntryReplicated; }) { + if (this.closed) return; + if (!this.entryCoordinatesIndex) return; + if (!this._replicationRangeIndex) return; + + try { let assignedToRangeBoundary = shouldAssignToRangeBoundary( properties.leaders, properties.replicas, @@ -3713,6 +3720,9 @@ export class SharedLog< ), }); } + } catch (e: any) { + if (!this.closed) throw e; + } } private async deleteCoordinates(properties: { hash: string }) { @@ -3918,6 +3928,8 @@ export class SharedLog< topics: string[], subscribed: boolean, ) { + if (this.closed) return; + if (!topics.includes(this.topic)) { return; } @@ -4463,6 +4475,8 @@ export class SharedLog< } async rebalanceParticipation() { + if (this.closed) return false; + // update more participation rate to converge to the average expected rate or bounded by // resources such as memory and or cpu