Skip to content

fix(retry): clean up pending retry intervals on abort or re-send #65

Description

@usernane

Problem

When the retry mechanism is active (using setInterval), calling send() again or navigating away does not clear the pending interval. This can cause:

  • Memory leaks (interval keeps running)
  • Double-sends (retry fires after a new send() was already initiated)
  • Unexpected behavior if the instance is reused

Current Implementation

this.retry.id = setInterval(function () {
    i.retry.passed++;
    i.retry.func(i.retry.wait - i.retry.passed, i.retry.pass_number);
    if (i.retry.passed === i.retry.wait) {
        clearInterval(i.retry.id);
        i.retry.passed = 0;
        i.retry.pass_number++;
        i.AJAXRequest.send();
    }
}, 1000);

Suggested Fix

  • Before starting a new send(), clear any existing retry interval
  • On abort(), clear the retry interval and reset retry state
  • Store interval ID on the instance (not just XHR) so it is accessible for cleanup

Expected Behavior

  • Only one retry cycle can be active at a time
  • Aborting cancels pending retries
  • Re-sending cancels pending retries from the previous request

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: mediumMedium priority issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions