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

Operation was rejected (seq but not src). Trying to rollback change locally. #379

Open
l-liava-l opened this issue Jun 7, 2015 · 6 comments

Comments

@l-liava-l
Copy link

Hi everyone!

Trying to use ShareJs, but have a problem with submitOp.
Model change, but new value is not set in mongoDB.

I have a warning message:
"Operation was rejected (seq but not src). Trying to rollback change locally."

What am i doing wrong?

client:

        var socket = new BCSocket('http://localhost:8002/channel', {reconnect: true});
        var share = new sharejs.Connection(socket);

        var doc = share.get('lists', '1433606385077');

        doc.subscribe(function(){
            console.log('onChange:', doc.getSnapshot());
        });

        doc.whenReady(function(){
            console.log('onReady: ', doc.getSnapshot());
            doc.submitOp([{p:['title', 4], si: 'test'}]);
        });

server:

(function(){
    var Duplex = require('stream').Duplex;
    var browserChannel = require('browserchannel').server
    var backend = require('livedb').client(require('livedb-mongo')(dbUrl));
    var share = require('share').server.createClient({backend: backend});
    var bodyParser = require('body-parser');
    var core = require('express')();
    var server = createServer();
    var dbUrl = 'mongodb://localhost:27017/todoList'

    core.use(bodyParser.json());     
    core.use(bodyParser.urlencoded({
      extended: true
    })); 

    core.use(function(req, res, next) {
        var headers = {
            'Cache-Control' : 'max-age:120'  
        };

        if(req.headers.origin){         
            res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
            res.setHeader('Access-Control-Allow-Methods',  'GET, POST, OPTIONS');
            res.setHeader('Access-Control-Allow-Headers', 'Content-Type, X-Requested-With, X-PINGOTHER');
            res.setHeader('Access-Control-Max-Age', 86400);
        }

        next();
    });

    var mongodb = require('mongodb').connect(dbUrl, function(err, db){
        var usersAPI = new require('./api/users')(core, db);
        var listsAPI = new require('./api/lists')(core, db, backend);

        core.use(browserChannel({webserver: server}, function(client){
            console.log('New session: ' + client.id +' from ' + client.address);
            var stream = new Duplex({objectMode: true});

            listsAPI(client);

            stream._read = function() {};
            stream._write = function(chunk, encoding, callback) {

            if(client.state !== 'closed') {
                client.send(chunk);
            }
                callback();
            };

            client.on('message', function(data) {
                stream.push(data);
            });

            client.on('close', function(reason) {
                stream.push(null);
            });

            stream.on('end', function() {
                client.close();
            });

            return share.listen(stream);
        }));
    }); 

    function createServer(){
        return core.listen(8002, function () {
            var host = server.address().address;
            var port = server.address().port;
            console.log('Server started on', host + ':' + port);
        });
    }
})();
@ygaradon
Copy link

ygaradon commented Jun 7, 2015

+1

@ygaradon
Copy link

i found this error came from the npm version, but if you are using the master branch everything work great!

@mschrepel
Copy link

I just removed my npm module and installed the master branch and started getting the same error. It works fine with 0.7.3, then fails with master branch and the most recent npm package.

@pedrosanta
Copy link
Contributor

Take notice that the builtin lib on /dist folder on npm package is outdated/has issues (#378, #382), but from what @mschrepel said, he also tried with the master branch, so...

@typpo
Copy link

typpo commented Jun 25, 2015

Same problem here. Specifying npm version 0.7.3 instead of the latest fixed it. The latest version does not have a text.js in the dist folder, whereas this one does.

@pedrosanta
Copy link
Contributor

Try to update to the newly released 0.7.40 and see if it happens, since the /dist folder lib was fixed.

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

5 participants