Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error cannot be intercepted request-timeout, body-timeout, etimedout, econnreset #107

Open
savasyarar opened this issue Nov 2, 2022 · 0 comments

Comments

@savasyarar
Copy link

savasyarar commented Nov 2, 2022

I get several errors that I want to catch.
However, I have tried to catch them, but I do not succeed.

The issue is the following: ECONNRESET, ETIMEDOUT, request-timeout, body-timeout.

When these errors occur, I want to set my error variable to true.

The app always crashes when these errors occur, I would like to prevent this by catching the error.

Platform and Version

NodeJS v16

Sample Code that illustrates the problem

const response = await fetch(loadedFeed[i], {
            retryOptions: {
                timeout: 3000,
                retryOnHttpResponse: function (response) {
                    if(response.status !== 200){
                        error = true;
                        console.log("Site not work");
                    }
                },
                retryOnHttpError(err){
                    if(err === true){
                        error = true;
                    }

                    if(err.message === 'ECONNRESET'){
                        error = true;
                    }

                    if(err.message === 'ETIMEDOUT'){
                        error = true;
                    }

                    if(err.message === 'request-timeout'){
                        error = true;
                    }

                    if(err.message === 'body-timeout'){
                        error = true;
                    }

                }
            }
        });

Logs taken while reproducing problem

C:\Users\admin\Desktop\v01\node_modules@adobe\node-fetch-retry\index.js:230
return reject(new FetchError(network timeout at ${url}, 'request-timeout'));
^
FetchError: network timeout at https://www.star.com.tr/rss/rss.asp?cid=14
at wrappedFetch (C:\Users\admin\Desktop\01\node_modules@adobe\node-fetch-retry\index.js:230:43)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
type: 'request-timeout'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant