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: destroy ydoc after persisting to prevent memory leaks in worker #13

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

EastSun5566
Copy link
Contributor

Clean up the ydoc instance after persisting since getDoc creates a new one each time in consumeWorkerQueue:

y-socketio-redis/src/api.js

Lines 227 to 231 in 8a837ea

async getDoc (room, docid) {
const ms = extractMessagesFromStreamReply(await this.redis.xRead(redis.commandOptions({ returnBuffers: true }), { key: computeRedisRoomStreamName(room, docid, this.prefix), id: '0' }), this.prefix)
const docMessages = ms.get(room)?.get(docid) || null
const docstate = await this.store.retrieveDoc(room, docid)
const ydoc = new Y.Doc()

const { ydoc, storeReferences, redisLastId } = await this.getDoc(room, docid)

ref: yjs/y-redis#36

@EastSun5566 EastSun5566 self-assigned this Jan 14, 2025
Copy link
Collaborator

@stanley2058 stanley2058 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working! 🚀

@stanley2058 stanley2058 merged commit f8cf03f into main Jan 14, 2025
1 check passed
@Yukaii Yukaii deleted the fix/destroy-ydoc-after-persisting-in-worker branch January 14, 2025 08:26
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.

2 participants