Skip to content

How can I filter socket hang up errors? #813

Open
@JSteunou

Description

@JSteunou

I'm using node-http-proxy for a while now, and I think I'm using it quite right catching errors like this

proxy.on('error', function(err, req, res) {
    // log
    // ...
    // handle
    if (!res.headersSent) {
        res.writeHead(500, { 'content-type': 'application/json' });
    }
    res.end(JSON.stringify({ error: 'proxy_error', reason: err.message }));
});

But I can have two cases that make a "socket hang up" error happen.

  1. Crash behind
  2. Client cancelling the request

Watching at my log I can make no differences between those two cases and it's quite frustrating. Before knowing about request abort (thank #527) I really though I have an error going on.

So, what's the best practice to filter the request.abort case out?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions