share / share/sharedb

transformPresence is not a function

Open
#423 6 comments 1 reaction 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

We're using ShareDB with the nickasd/sharedb-codemirror connector. The editor content is synchronized well and now we want to show other editor's cursors via ShareDB's presence feature.

Creating the doc on the server:

var doc = conn.get('docs', uuid.v4())
doc.create({content: '', metaData: {...}}, null, {}, err => {})

Connecting to the doc from the client:

var doc = conn.get('collection', doc_id)
doc.fetch(callback)
var presence = conn.getDocPresence('collection', doc.id)
var localPresence = presence.create(new ObjectID().toString())

Error message on document edit:

bundle.js:25816 Uncaught TypeError: Cannot read property 'content' of undefined
    at ShareDBCodeMirror.assertValue (bundle.js:25816)
    at ShareDBCodeMirror.afterLocalChanges (bundle.js:25925)
    at ShareDBCodeMirror.codeMirrorChanges (bundle.js:25728)
    at signal (bundle.js:12762)
    at endOperation_finish (bundle.js:16102)
    at endOperations (bundle.js:16003)
    at bundle.js:15986
    at finishOperation (bundle.js:14244)
    at endOperation (bundle.js:15983)
    at runInOp (bundle.js:16112)
assertValue @ bundle.js:25816
afterLocalChanges @ bundle.js:25925
ShareDBCodeMirror.codeMirrorChanges @ bundle.js:25728
signal @ bundle.js:12762
endOperation_finish @ bundle.js:16102
endOperations @ bundle.js:16003
(anonymous) @ bundle.js:15986
finishOperation @ bundle.js:14244
endOperation @ bundle.js:15983
runInOp @ bundle.js:16112
TextareaInput.poll @ bundle.js:21717
(anonymous) @ bundle.js:21502
bundle.js:25717 TypeError: this._doc.type.transformPresence is not a function
    at LocalDocPresence._transformAgainstOp (bundle.js:27856)
    at emitThree (bundle.js:23452)
    at Doc.emit (bundle.js:23511)
    at Doc._otApply (bundle.js:27357)
    at Doc._submit (bundle.js:27461)
    at Doc.submitOp (bundle.js:27562)
    at ShareDBCodeMirror.afterLocalChanges (bundle.js:25919)
    at ShareDBCodeMirror.codeMirrorChanges (bundle.js:25728)
    at signal (bundle.js:12762)
    at endOperation_finish (bundle.js:16102)

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 with the getDocPresence usage and the LocalDocPresence._transformAgainstOp stack entry shown in the error, then inspect how the document type is selected for this ShareDB connection. Reproduce the CodeMirror edit with presence enabled and confirm that edits no longer throw a transformPresence error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.