stop showing EPIPE #9

Merged
merged 1 commit into from May 29, 2012

Projects

None yet

2 participants

@tricknotes
Contributor

json-command is a nice tool!
Whenever I parse json, I use this awesome product.

But the following error occurred, when I give large buffer and use pager:

$ node --version
v0.6.18
$ pwd
~/json_command
$ seq 1 10000 | ./bin/json.js | less

And close pager without reading all buffer:

events.js:48
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: write EPIPE
    at errnoException (net.js:670:11)
    at Object.afterWrite [as oncomplete] (net.js:503:19)

The reason why this error occurred, process.stdout.write throw error EPIPE when the pager(such as less, lv) closed before reading all buffer.

I think that this case should not throw error.
Therefor, I stopped showing this error in the way to ignore EPIPE.

I tested my patch in the following node versions:

v0.4.12
v0.6.18
v0.7.8
Contributor

This patch maybe fixes #5.
I replicated the error of #5 using node v0.4.12.

$ node --version
v0.4.12
$ pwd
~/json_command
$ seq 1 10000 | ./bin/json.js | less

And exit pager:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: EPIPE, Broken pipe
    at Socket._writeImpl (net.js:159:14)
    at Socket._writeOut (net.js:444:25)
    at Socket.write (net.js:377:17)
    at [object Object].processObjects (/Users/rsato/Documents/dev/json-command/lib/jsonCommand.js:394:24)
    at Socket.<anonymous> (/Users/rsato/Documents/dev/json-command/lib/jsonCommand.js:451:40)
    at Socket.emit (events.js:64:17)
    at Socket._onReadable (net.js:667:31)
    at IOWatcher.onReadable [as callback] (net.js:177:10)

When this patch applied, this error is not occurred.

@zpoley zpoley merged commit 056fc2d into zpoley:master May 29, 2012
Contributor

Thanks for your merging ❤️

Owner
zpoley commented May 29, 2012

Thanks tricknotes! Great work. Merged and published in json@0.0.11.

Contributor

I'll install immediately 😄

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