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

Abort signal not working #738

Open
mokkymiah opened this issue Sep 21, 2023 · 1 comment
Open

Abort signal not working #738

mokkymiah opened this issue Sep 21, 2023 · 1 comment

Comments

@mokkymiah
Copy link

mokkymiah commented Sep 21, 2023

When signal is passed and aborted, the promise is not rejecting.

Same code with native fetch works as intended.

image

On catch, abort needs to be ignored from retry

@mokkymiah
Copy link
Author

mokkymiah commented Sep 21, 2023

Unable to submit a PR but here is a quick patch;

                        if (error && error.name && error.name == "AbortError") {
                            reject(error);
                          } else {

                            if (retryOnFn(attempt, frp.retries, error, null)) {
                                // eslint-disable-next-line @typescript-eslint/no-use-before-define
                                retry(attempt, error, null);
                            } else {
                                reject(error);
                            }
                          }

alternative bypass using custom retyOn method;

  retryOn: (
    attempt: number,
    retries: number,
    error: Error | null,
    response: Response | null
  ) => {
    if (error && error.name && error.name == "AbortError") {
      return false;
    }

    if (response && retryCodes.includes(response.status)) {
      if (attempt > retries) {
        return false;
      }

      return true;
    }

    return false;
  },

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