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

expected Scuttlebutt #2

Closed
juliangruber opened this issue Feb 24, 2013 · 18 comments
Closed

expected Scuttlebutt #2

juliangruber opened this issue Feb 24, 2013 · 18 comments

Comments

@juliangruber
Copy link
Contributor

This

/Users/julian/git/****/node_modules/level-scuttlebutt/lib/buffered-opener.js:29
      throw new Error('expected Scuttlebutt')

can be reproduced by this:

var levelup = require('levelup');
var levelScuttlebutt = require('level-scuttlebutt');
var Model = require('scuttlebutt/model');
var udid = require('udid');

var db = levelup(__dirname + '/db');
levelScuttlebutt(db, udid, function (name) {
  return new Model();
});
db.scuttlebutt.open('some-name', function (err, model) {});

Has the API changed?

@dominictarr
Copy link
Owner

will work if you wait until the db has opened before opening scuttlebutt.
I may change it so it buffers, but I'll have to read through all the leveldb buffering code.

@juliangruber
Copy link
Contributor Author

doesn't levelup already buffer all calls?

@juliangruber
Copy link
Contributor Author

You mean like:

var levelup = require('levelup');
var levelScuttlebutt = require('level-scuttlebutt');
var Model = require('scuttlebutt/model');
var udid = require('udid');

levelup(__dirname + '/db', function (err, db) {
  if (err) throw err;
  levelScuttlebutt(db, udid, function (name) {
      return new Model();
  }); 
  db.scuttlebutt.open('some-name', function (err, model) {});
});

...? That still throws:

/Users/julian/git/***/node_modules/level-scuttlebutt/lib/buffered-opener.js:29
      throw new Error('expected Scuttlebutt')
            ^
Error: expected Scuttlebutt
    at /Users/julian/git/***/node_modules/level-scuttlebutt/lib/buffered-opener.js:29:13
    at Function.cached [as open] (/Users/julian/git/***/node_modules/level-scuttlebutt/lib/cache.js:57:5)
    at /Users/julian/git/***/index.js:95:18
    at LevelUP.open (/Users/julian/git/***/node_modules/levelup/lib/levelup.js:114:17)

@juliangruber
Copy link
Contributor Author

Btw the map-reduce test fails on my machine. Also I saw that your tests use the

var db = levelup(path)

pattern too?

@dominictarr
Copy link
Owner

I removed that because I thought it was breaking other stuff. I'll look into this soon. I'll move reverting this to the top of my list.

@dominictarr
Copy link
Owner

Hey, I added a test for this, but your code isn't breaking.
tests pass for me, are you at the latest master?

dominictarr added a commit that referenced this issue Feb 28, 2013
@juliangruber
Copy link
Contributor Author

I just updated and reinstalled all dependencies. I still get this output:

 ∴  level-scuttlebutt (master) : npm test

> level-scuttlebutt@4.2.3 test /Users/julian/git/level-scuttlebutt
> set -e; for t in test/*.js; do node $t; done

TAP version 13
# test
ok 1 should be equivalent

1..1
# tests 1
# pass  1

# ok
TAP version 13
# scuttlebutt: map-reduce
open
open
open
open
open
map test-a
map test-b
map test-c
map test-d
map test-e
r [ [ 'square' ], 30 ]
r [ [ 'cube' ], 100 ]
map test-a
map test-b
map test-c
map test-d
map test-e

timers.js:103
            if (!process.listeners('uncaughtException').length) throw e;
                                                                      ^
Error: "end() already called on iterator"
    at ReadStream._cleanup (/Users/julian/git/level-scuttlebutt/node_modules/levelup/lib/read-stream.js:144:20)
    at ReadStream.destroy (/Users/julian/git/level-scuttlebutt/node_modules/levelup/lib/read-stream.js:80:8)
    at Model.module.exports.opener.open.value (/Users/julian/git/level-scuttlebutt/lib/db-opener.js:65:14)
    at Model.g (events.js:192:14)
    at Model.EventEmitter.emit (events.js:126:20)
    at Model.sb.dispose (/Users/julian/git/level-scuttlebutt/node_modules/scuttlebutt/index.js:237:8)
    at Object._onTimeout (/Users/julian/git/level-scuttlebutt/lib/cache.js:88:25)
    at Timer.list.ontimeout (timers.js:101:19)
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

@juliangruber
Copy link
Contributor Author

Maybe its a race condition?

@juliangruber
Copy link
Contributor Author

We should have something like browserling for this, or a travis-ci with different operating systems and simulated hardware

@dominictarr
Copy link
Owner

cool, reproduced!

Okay, it's now hanging on the map-reduce test, but the others are passing.

was there something about levelup taking too long to compile to work with travis-ci ? I think @rvagg mentioned something about that?

@rvagg
Copy link

rvagg commented Feb 28, 2013

I vaguely remember something about things taking too long and Travis timing out but if that was a problem it hasn't been for a long time now. Travis is happy with LevelUP and hasn't complained.
Is this using LevelUP 0.6? If so then a double end() called on an iterator might be a new LevelUP bug. It shouldn't be possible, the ReadStream should know not to do that regardless what it's told to do by client code.

@juliangruber
Copy link
Contributor Author

My installed version of levelup is 0.5.4

@rvagg
Copy link

rvagg commented Mar 1, 2013

ok, I think that we fixed some issues in this area in that version but shifting to 0.6 wouldn't hurt

@juliangruber
Copy link
Contributor Author

I just updated to 0.6.0 and it still fails with the same error 🐹

@rvagg
Copy link

rvagg commented Mar 1, 2013

same issue? dominictarr/level-map#1

@rvagg
Copy link

rvagg commented Mar 1, 2013

levelup@0.6.1 ought to fix this.

@juliangruber
Copy link
Contributor Author

sweet, I don't get an error any more! Now the map-reduce test never finishes :O t.end() is called but it still continues mapping and reducing

@dominictarr
Copy link
Owner

hmm, well I update levelup in level-map and level-reduce, and it doesn't spin around reducing and reducing.
It's just level-scuttlebutt.

I'm planning a refactor that will simplify the interaction between level-scuttlebutt and map-reduce,
that will make all this much simpler.

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

3 participants