Skip to content

Conversation

stanley2058
Copy link
Collaborator

@stanley2058 stanley2058 commented Sep 4, 2025

This PR includes:

  • Client would now try to resync whenever it detects an update is not being ack-ed from the server for over 3s
    • Side note: double-submitting is not an issue, yjs ignores duplicated updates.
  • Server persistent leader
    • Use a Redlock-like mechanism to ensure persistDoc is only called once per namespace.
  • Allow supplying a full socket instance to the client provider
    • This allows patching methods for testing; one MUST make sure the connection string is correct, since it's different from the one passed to the provider.
  • Fix tsup broken due to incorrect Redis import
  • Silent Redis client closed error (improve SNR in automated testing)

@stanley2058 stanley2058 changed the title fix/client resync mechanism & quality-of-life improvements fix/client resync mechanism & server persist leader & quality-of-life improvements Sep 10, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements client resync mechanisms, server persistent leader functionality, and several quality-of-life improvements to enhance reliability and testing capabilities.

Key changes:

  • Client auto-resync when updates aren't acknowledged within 3 seconds
  • Server persistent leader using Redis-based distributed locking to prevent duplicate persistDoc calls
  • Allow custom socket instance injection for testing purposes

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/y-socket-io/y-socket-io.js Implements persistent leader mechanism, client resync support, and error handling improvements
src/y-socket-io/client.js Adds update acknowledgment with timeout and retry logic for client resync
src/server.js Removes logging import and improves server shutdown handling
src/api.js Fixes Redis import to use named imports instead of namespace import
package.json Updates yjs dependency version
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +806 to +807
async registerPersistentLeaderHeartbeat () {
this.persistentHeartbeatTimeout = setTimeout(async () => {
Copy link
Preview

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

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

[nitpick] The method name 'register' is misleading since it's recursively scheduling itself. Consider renaming to 'scheduleHeartbeat' or 'runHeartbeatCycle' to better reflect its behavior.

Copilot uses AI. Check for mistakes.

Comment on lines +374 to 375
// @ts-ignore
formData.append('ydoc', new Blob([Y.encodeStateAsUpdateV2(ydoc)]))
Copy link
Preview

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

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

[nitpick] The @ts-ignore comment lacks explanation. Consider adding a comment explaining why the type checking is being suppressed or fix the underlying type issue.

Copilot uses AI. Check for mistakes.

@Yukaii Yukaii merged commit 56fe6b0 into main Sep 16, 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