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

Question client doc handleOp not debounce ? #604

Open
Qquanwei opened this issue Apr 3, 2023 · 0 comments
Open

Question client doc handleOp not debounce ? #604

Qquanwei opened this issue Apr 3, 2023 · 0 comments

Comments

@Qquanwei
Copy link

Qquanwei commented Apr 3, 2023

Fetch only sends a new fetch command if no fetches are inflight in source code, but in the real environment is not. fetch is not natural debouncing, when receive multiple op action from other client, it will send multiple fetch command to server, and receive multiple op segments (same ops) from server.

source: https://github.com/share/sharedb/blob/master/lib/client/doc.js#L329

Doc.prototype._handleOp = function(err, message) {
  ...

  if (this.version == null || message.v > this.version) {
    // This will happen in normal operation if we become subscribed to a
    // new document via a query. It can also happen if we get an op for
    // a future version beyond the version we are expecting next. This
    // could happen if the server doesn't publish an op for whatever reason
    // or because of a race condition. In any case, we can send a fetch
    // command to catch back up.
    //
    // Fetch only sends a new fetch command if no fetches are inflight, which
    // will act as a natural debouncing so we don't send multiple fetch
    // requests for many ops received at once.
    this.fetch();
    return;
  }
  ...

image

receive multiple same op segments

image

Qquanwei pushed a commit to Qquanwei/sharedb that referenced this issue May 9, 2023
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

No branches or pull requests

1 participant