question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retries [Feature]

See original GitHub issue

Expected behavior

Ability to have the proxy automatically retry on events like ‘ECONNREFUSED’.

Proposed api

I imagine it would look something like this:

{
  target: 'localhost:9090',
  retry: {
    timeout: 1000,
    limit: 10
  }
}

Where the proxy would attempt the request again on failure every 1 second for at least 10 times.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
SystemParadoxcommented, Sep 25, 2017

For the case when the server is in a separate process, I created a connection to monitor the state of the server like this:

new WebpackDevServer({
    ...,
    setup: function (app) {
        var net = require('net');
        var opts = { port: 8082 };
        var socket = net.connect(opts);
        var connected = false;
        socket.on('connect', function () {
            console.log('[PROXY] connected');
            connected = true;
        }); 
        socket.on('error', function (err) {
            console.log('[PROXY] Error: ' + err.message);
        }); 
        socket.on('close', function (err) {
            console.log('[PROXY] closed');
            connected = false;
            setTimeout(function () {
                console.log('[PROXY] connecting...');
                socket.connect(opts);
            }, 1000);
        }); 
        app.use(function (req, res, next) {
            if (connected) {
                next();
            } else {
                socket.once('connect', function () {
                    next();
                }); 
            }   
        }); 
    }   
}
0reactions
SystemParadoxcommented, Sep 12, 2017

Ah I see. Yes my server is a different process (spawned with node-dev) so I can’t find out if it’s listening so easily.

Thanks for the snippet though, might still come in handy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retries — Boto3 Docs 1.26.37 documentation - Amazon AWS
Boto3 provides many features to assist in retrying client calls to AWS services when these kinds of errors or exceptions are experienced.
Read more >
Smart retries | Stripe Documentation
The Smart Retries feature attempts to retry the customer's charge up to eight times within a customizable time frame and supports cards.
Read more >
Error handling and automatic retries in AWS Lambda
When you invoke a function, two types of error can occur. Invocation errors occur when the invocation request is rejected before your function...
Read more >
Retry Flaky Tests - WebdriverIO
You can rerun certain tests with the WebdriverIO testrunner that turn out to be unstable due to things like a flaky network or...
Read more >
Test Retries - Cypress Documentation
How to configure test retries Introduction End-to-end (E2E) tests excel ... You will need to enable test retries in your configuration to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found