Skip to content

Commit

Permalink
BC-8431 - improve console logs in API service and ioredis adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
bergatco committed Nov 25, 2024
1 parent 95859eb commit 0065923
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/infra/redis/ioredis.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ export class IoRedisAdapter implements RedisAdapter {
}

public async deleteMessagesFromStream(streamName: string): Promise<number> {
console.log('deleteMessagesFromStream', streamName);

const result = await this.redis.xtrim(streamName, 'MAXLEN', 0);
console.log('deleteMessagesFromStream', result);

return result;
}
Expand Down
4 changes: 3 additions & 1 deletion src/infra/y-redis/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ export class Api {
};

if (ydoc.store.pendingStructs !== null) {
console.log(`Document has pending structs ... retry with ${count + 1000} messages.`);
console.log('Document has pending structs.');
const streamLength = await this.redis.getEntriesLen(roomComputed);
if (streamLength < count) {
console.log('Pending structs can not be fixed with updates from stream. Deleting all messages from stream.');
await this.redis.deleteMessagesFromStream(roomComputed);
count = 0;
}
console.log(`Retry with ${count + 1000} messages.`);
response = await this.getDoc(room, docid, count + 1000);
}

Expand Down

0 comments on commit 0065923

Please sign in to comment.