GraftJS / jschan

JavaScript port of libchan based around streams
MIT License
157 stars 9 forks source link

Echoed embedded channels break pipes #28

Closed AdrianRossouw closed 9 years ago

AdrianRossouw commented 9 years ago

One of the things I've need to do in aetherboard is to have a writechannel for all my messages to the server, and then a read channel that is meant to contain the merged stream of everybody's messages in the order they were received.

Inside the message I send, I have another write channel that contains a series of messages that I will write to even after the initial message is sent. This is actually not that uncommon. think IRC with the ability to see everybody's text as they type.

Unfortunately the message I receive back from the server, is somehow different for me than for all the other people who receive the message, and beyond that, it is also different to my initial writechannel.

Trying to pipe from it, causes some kind of silent error, and unpipes everything, meaning that my client becomes disconnected.

This behaviour can be reproduced with aetherboard by following this issue : https://github.com/AetherBoard/aetherboard/issues/16

I have written some tests for graft in this PR : https://github.com/GraftJS/graft/pull/13

I'm pretty sure though that the bug is actually going to be found here in jschan though.

encoder.js possible bug location

I've also noticed that the passing around of the original channel is causing the chan.streams to contain circular references in there.

@mcollina

mcollina commented 9 years ago

That line is needed to support automatic Readable/Writable conversion, so something might be changed there: right now it sounds "do not recode a channel if it's part of this session". However we can make it much more granular, if we understand it correctly.

Moreover, I should improve the whole msgpack5 encoding, which is a bit messy at the moment.

AdrianRossouw commented 9 years ago

i ended up fixing it this way (your patch to allow through streams helped) : https://github.com/AetherBoard/aetherboard/commit/089836d37895ad339ee0ac52dead30a5ebc959fe

mcollina commented 9 years ago

yeah :), that's the way it should be fixed.. I'm waiting for a reply by the folks in libchan anyway on this.