Skip to content
This repository was archived by the owner on Sep 25, 2020. It is now read-only.
This repository was archived by the owner on Sep 25, 2020. It is now read-only.

Catching handleOrProxy errors when request is sent to node that has failed. #303

@sashahilton00

Description

@sashahilton00

When testing Ringpop in a small cluster, I have been testing how ringpop handles node failures. When a node goes down, and a request is handleOrProxy()'d, there is a period of approximately 5 seconds where ringpop continues to forward requests to the dead node. Whilst this is expected, it throws a rather ugly error response: tchannel socket error (ECONNREFUSED from connect): connect ECONNREFUSED 10.2.0.17:9880. Is there any way that an extra argument could be added to the handleOrProxy() method that would be called when such an error occurs so that we can send a formatted response that our application can read? eg. handleOrProxy(req, res, errCallback) where errCallback is something like the example below:

function errCallback (err, req, res) {
    switch (err) {
        case 'ECONNREFUSED':
        res.end(JSON.stringify({status: 'failed', error: 'connection_refused', message: 'Could not connect to the correct server.', retry_in: 5}));
        break;

        case 'ETIMEDOUT':
        res.end(JSON.stringify({status: 'failed', error: 'connection_timeout', message: 'The connection timed out.', retry_in: 20}));
        break;

        //etc.
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions