Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/prevent trimming stream after removed #24

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

stanley2058
Copy link
Collaborator

@stanley2058 stanley2058 commented Jan 23, 2025

There's a possibility that the stream would be deleted before xTrim is called. When persisting in worker, a promise is created and would resolve once the worker is done processing persisting.

Where this line would be called:

this.client?.trimRoomStream(namespace, 'index', true)

Before this line:

await this.client.trimRoomStream(namespace, 'index')

Due to here also waiting on the same promise:

if (awaitingPersist) await awaitingPersist.promise

In this PR, we check if the namespace still exists before calling on the trim function. The namespace is deleted here:

this.namespaceDocMap.delete(namespace)

Just before deleting the stream, so we can assume the stream still exists in Redis if the namespace is still alive.

@jackycute jackycute requested a review from Yukaii January 24, 2025 06:55
@Yukaii Yukaii merged commit 4ca7393 into main Jan 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants