Thanks for the explanation!  Yeah, definitely emitting end twice would be something to avoid.  I don't think it should be too hard, just have a like 'this._ended' flag or something on the client, set it the first time, and check if it's set & don't emit.  What you think?