share / share/sharedb

Question client doc handleOp not debounce ?

Open
#604 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6.5k
Forks
456
Avg merge
1d 5h
Merged PRs (30d)
5

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/client/doc.js at Doc.prototype._handleOp and read the surrounding fetch handling. Reproduce the reported case of multiple op actions from another client, then compare the observed fetch requests and returned op segments with the comment's claim about debouncing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.