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

Request timeout not using abort signal #160

Open
AlissonRS opened this issue Oct 4, 2024 · 1 comment
Open

Request timeout not using abort signal #160

AlissonRS opened this issue Oct 4, 2024 · 1 comment

Comments

@AlissonRS
Copy link

AlissonRS commented Oct 4, 2024

In the utils.ts file, the function below is used to send request via Fetch API:

        const requestWrapper = (): Promise<Response> => {
            return new Promise((resolve, reject) => {
                let timeoutId: NodeJS.Timeout;
                if (timeout) {
                    timeoutId = setTimeout(() => reject('error: timeout'), timeout);
                }
                return fetch(url, fetchOptions)
                    .then(res => resolve(res))
                    .catch(err => reject(err))
                    .finally(() => {
                        if (timeoutId) {
                            clearTimeout(timeoutId);
                        }
                    });
            });
        };

This is timing out the promise, but not really aborting the request, which keeps http connections open hanging.

It'd be nice if abort signal was used so the http connection is also closed.

@matthewelwell
Copy link
Contributor

Thanks for raising this @AlissonRS, and submitting a PR. I've added a comment to the PR - let's continue the discussion there.

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

Successfully merging a pull request may close this issue.

2 participants