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 during retry causes uncaught exception #278

Closed
finbargp opened this issue Jun 20, 2024 · 3 comments · Fixed by #279
Closed

Abort during retry causes uncaught exception #278

finbargp opened this issue Jun 20, 2024 · 3 comments · Fixed by #279

Comments

@finbargp
Copy link

We're seeing an issue where an abort during a retry causes an uncaught exception which is bringing our server down. We believe this may have been introduced by #273 as it has only started happening since then.

An example test to reproduce this (based on existing should clear timeout if started test) is below:

This is currently failing with an uncaught exception.

Can someone please have a look?

Please let me know if you need any further information.

        it('should cancel old requests', (done) => {
          const client = axios.create();
          setupResponses(client, [
            () => nock('http://example.com').get('/test').delay(100).reply(429),
            () => nock('http://example.com').get('/test').delay(100).reply(429),
            () => nock('http://example.com').get('/test').delay(100).reply(429),
          ]);
          axiosRetry(client, {
            retries: 2,
            retryCondition: () => true,
            retryDelay: () => 0,
          });
          const abortController = new AbortController();
          client
            .get('http://example.com/test', { signal: abortController.signal })
            .then(
              () => done.fail(),
              (error) => {
                expect(error).toBeInstanceOf(CanceledError);
                expect(new Date().getTime() - timeStart).toBeLessThan(300);
                done();
              },
            )
            .catch(done.fail);
          setTimeout(() => abortController.abort(), 250);
          const timeStart = new Date().getTime();
        });
@mindhells
Copy link
Member

@michal-billtech could you have a look into this?

@michal-billtech
Copy link
Contributor

Sure!

@michal-billtech
Copy link
Contributor

Thanks for reporting this. The issue seems to be caused by abort listener not being cleared. PR on the way

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.

3 participants