Unexpected token illegal -- (Another?) JSON framing race-condition? #126

danlec opened this Issue Jul 18, 2011 · 1 comment


None yet
2 participants

danlec commented Jul 18, 2011

Note: A similar issue existed before (#64) and was resolved, however I'm using 0.6.4, which includes that fix, and still having the same symptoms described in that ticket

Sometimes (rarely) when several workers crash and are restarted simultaneously, the cluster master process will crash with something like the following:

s> ({"args":[],"
SyntaxError: Unexpected token ILLEGAL
    at Object.parse (native)
    at Master.frame (/usr/home/trellis/trellis-0.4.50/node_modules/cluster/lib/mixins/receiver.js:32:24)
    at Socket. (/usr/home/trellis/trellis-0.4.50/node_modules/cluster/lib/master.js:144:12)
    at Socket.emit (events.js:64:17)
    at Socket._onReadable (net.js:673:31)
    at IOWatcher.onReadable [as callback] (net.js:177:10)

I know that 0384fcb, the fix for #64, made it so there is a buffer per socket file descriptor; is it possible that there could still be concurrency issues? (Are the sockets re-used? Could it be related to the way works attempt to shutdown gracefully in close() if connections exist?)

I've been trying to come up with a repro, and haven't been able to... I just know that it happens sometimes in 0.6.4


tj commented Jul 18, 2011

there were a few different issues regarding buffering, one I couldn't really reproduce with workers writing half of a json message, dying, re-spawning, using the same id to buffer some more json causing it to be invalid. I'll see if I have time today to refactor things to get away from the single IPC socket and fix this thing

tj closed this in b72287b Jul 18, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment