Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Minor bug when using dnode synchronously #108

ashtuchkin opened this Issue · 1 comment

2 participants


When both client and server are in one process (scenario: unit tests), there could be several callbacks back-and-fourth synchronously through the dnode. After 2-3 callbacks, the dnode stops responding.

I tracked down the error (see -
the self._line variable should be cleaned before calling self.handle(row), because inside that fn we could eventually call dnode.write again and this would append new json to the uncleaned self._line, which will break JSON.parse. Also, it would be great to emit the json.parse error, because now the stream just ends without any indication of error.

TL;DR - lines 126 and 127 should be swapped.

Current code:

dnode.prototype.write = function (buf) {
        for (var i = 0; i < buf.length; i++) {
            if (buf.charCodeAt(i) === 0x0a) {
                try { row = json.parse(self._line) }
                catch (err) { return self.end() }

                self._line = '';
            else self._line += buf.charAt(i)

Thanks for tracking this down and fixing it! Sorry for the delay.

@substack substack closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.