Error: write EPIPE

3,743 views
Skip to first unread message

Gustavo Machado

unread,
Feb 19, 2013, 3:47:20 PM2/19/13
to nod...@googlegroups.com
Hi,

We are getting EPIPE errors. Reproducing the error is a matter of uploading multiple files at the same time while keep on using the site, and eventually it will throw.

Here is the stack trace:

"stack":[
"Error: write EPIPE",
" at errnoException (net.js:770:11)",
" at Object.afterWrite (net.js:594:19)"
],

Node version: 0.8.16

What is the right way to handle/avoid this potential error? Any documentation I could look into?

On a somewhat related note, what's the status of domains?

Thanks,

Gustavo Machado
mach...@gmail.com



Ben Noordhuis

unread,
Feb 19, 2013, 4:24:39 PM2/19/13
to nod...@googlegroups.com
On Tue, Feb 19, 2013 at 12:47 PM, Gustavo Machado <mach...@gmail.com> wrote:
> Hi,
>
> We are getting EPIPE errors. Reproducing the error is a matter of uploading multiple files at the same time while keep on using the site, and eventually it will throw.
>
> Here is the stack trace:
>
> "stack":[
> "Error: write EPIPE",
> " at errnoException (net.js:770:11)",
> " at Object.afterWrite (net.js:594:19)"
> ],
>
> Node version: 0.8.16
>
> What is the right way to handle/avoid this potential error? Any documentation I could look into?

EPIPE means you're writing to a pipe or socket when the other end has
terminated the connection.

It's a run-time error; there is nothing you can do but close your end as well.

> On a somewhat related note, what's the status of domains?

Alive and well?

> Thanks,
>
> Gustavo Machado
> mach...@gmail.com

Gustavo Machado

unread,
Feb 20, 2013, 7:07:32 AM2/20/13
to nod...@googlegroups.com
Hi Ben,
 
EPIPE means you're writing to a pipe or socket when the other end has
terminated the connection.

It's a run-time error; there is nothing you can do but close your end as well.

Since it's throwing, looks like I have to add some try/catch in order to be able to close my end (am I right?). Judging by the stack trace, I won't be able to do so. Can you point me to some more information on how to handle this exception?

Thanks,
Gustavo Machado

Ben Noordhuis

unread,
Feb 20, 2013, 7:59:07 AM2/20/13
to nod...@googlegroups.com
You catch it by installing an 'error' event listener on the socket
object, like this:

var conn = net.createConnection(...);
conn.on('error', function(err) {
console.log('caught ' + err);
});

(Ditto for dgram/http/https/etc. objects.)

Gustavo Machado

unread,
Feb 21, 2013, 12:17:55 PM2/21/13
to nod...@googlegroups.com
Hi,

In turned out to be the process.stdout. Apart from reducing the console.logs to a minimum, we are planning to use epipebomb to avoid the process to crash under heavy load. Is there any way to re-open the connection to the console.log after it's been EPIPE'd ?

Thanks,

Gustavo Machado
mach...@gmail.com
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ben Noordhuis

unread,
Feb 21, 2013, 5:05:37 PM2/21/13
to nod...@googlegroups.com
On Thu, Feb 21, 2013 at 6:17 PM, Gustavo Machado <mach...@gmail.com> wrote:
> Hi,
>
> In turned out to be the process.stdout. Apart from reducing the console.logs to a minimum, we are planning to use epipebomb to avoid the process to crash under heavy load. Is there any way to re-open the connection to the console.log after it's been EPIPE'd ?
>
> Thanks,
>
> Gustavo Machado
> mach...@gmail.com

What is process.stdout pointing to (tty, pipe, file)?

To answer your question about reopening process.stdout, you could do
something like this:

var fd = fs.openSync('/dev/tty', 'w');
process.stdout = new net.Socket({ fd: fd });

Gustavo Machado

unread,
Feb 22, 2013, 8:50:38 AM2/22/13
to nod...@googlegroups.com
Normally it would either be the tty (we are running on windows) or the tty from a child_process, something like this:

var exec = require("child_process").exec,
    path = require("path");

function executeCommand(command, folder, callback){
    var childProc = exec(command, {
        cwd: path.join(__dirname, folder)
    }, callback || function(){});
    childProc.stdout.pipe(process.stdout);
    childProc.stderr.pipe(process.stderr);
}

Thanks,
Gustavo


Reply all
Reply to author
Forward
0 new messages