Repository navigation
use setImmediate in peek - #2
max-mapper wants to merge 1 commit into
Conversation
|
hmm, can you show me a stacktrace this produced, there may be a better place to put this fix. |
|
sure: /Users/max/src/js/dat/node_modules/tape/index.js:51
throw err
^
TypeError: Cannot call method 'toString' of undefined
at /Users/max/src/js/dat/node_modules/level-mutex/node_modules/level-peek/index.js:32:22
at Stream.onEvent (/Users/max/src/js/dat/node_modules/level-mutex/node_modules/level-peek/index.js:12:10)
at Stream.EventEmitter.emit (events.js:95:17)
at Stream.<anonymous> (/Users/max/src/js/dat/node_modules/multilevel/node_modules/tmp-stream/index.js:42:10)
at Stream.EventEmitter.emit (events.js:117:20)
at destroyAll (/Users/max/src/js/dat/node_modules/multilevel/node_modules/mux-demux/inject.js:80:11)
at Stream.<anonymous> (/Users/max/src/js/dat/node_modules/multilevel/node_modules/mux-demux/inject.js:65:5)
at Stream.EventEmitter.emit (events.js:117:20)
at Stream.stream.end (/Users/max/src/js/dat/node_modules/multilevel/node_modules/mux-demux/node_modules/duplex/index.js:76:12)
at Stream.onend (stream.js:79:10) |
|
now that you mention it I think it should go in mux-demux or multilevel |
|
my guess is there is a try...catch around an |
|
do you have a test case that reproduces this? hmm, so basically, this is being triggered, which happens when the stream is ended, but there are inner stream that havn't been closed yet. Can you think what might be closing the websocket(? or whatever sort of stream it is) https://github.com/dominictarr/mux-demux/blob/master/inject.js#L73 |
|
yea I'm closing the connection in my test: https://github.com/maxogden/dat/blob/master/test/tests/init.js#L130 (in the cleanup function) I did notice that in multilevel you can't access or pass options in to |
|
p.s. if you take the setImmediate out of that test it will throw an error |
|
multilevel uses that mux-demux setting so that if any callbacks are in progress when the other stream closes they will callback an error. Ah, I think I see it. I think if you try calling https://github.com/maxogden/dat/blob/master/lib/commands.js#L322-L329 |
this fixes a bug where I was destroying things in the callback of a peek() which was mistakenly causing the peek error event to get called