Skip to content

[bug] resetApiState() triggers AbortController Illegal invocation when used with a retry() wrap in RTKQ in v2.9.2+ #5148

@AndreaCuneo

Description

@AndreaCuneo

Upgrading from v2.9.1 to v2.10.1 cause error "Failed to execute 'abort' on 'AbortController': Illegal invocation"

The error happens during Cypress tests cleanup when dispatching resetApiState(). The API is use retry() over fetchBaseQuery() with a timeout setting which, browsing the code, uses an AbortController in the fetchBaseQuery().

Checking release notes is likely got introduced in v2.9.2 although glancing at code changes I don't see the immediate culprit but my assumption is that now retry() propagates the abort signal to fetchBaseQuery() and trigger the error.

My stacktraces are bundled as I run e2e tests on the vite build so I've nothing to paste here that is readable.

[run]   TypeError: Illegal invocation
[run]       at Promise.S [as abort] (http://localhost:3000/assets/rtk-DynrW8Eq.js:1:26029)
[run]       at P (http://localhost:3000/assets/rtk-DynrW8Eq.js:1:57456)
[run]       at g (http://localhost:3000/assets/rtk-DynrW8Eq.js:1:57760)
[run]       at <unknown> (http://localhost:3000/assets/rtk-DynrW8Eq.js:1:64914)
[run]       at <unknown> (http://localhost:3000/assets/rtk-DynrW8Eq.js:1:64830)
[run]       at Object.dispatch (http://localhost:3000/assets/rtk-DynrW8Eq.js:1:20601)
[run]       at Object.resetCache (http://localhost:3000/assets/initGlobals-CbEWBp_i.js:35:148820)
[run]       at Context.eval (webpack://ark.starters.spa/./cypress/support/e2e.ts:11:27)
[run]       at getRet (http://localhost:3000/__cypress/runner/cypress_runner.js:122456:20)
[run]       at tryCatcher (http://localhost:3000/__cypress/runner/cypress_runner.js:1777:23)
getResetApiActions = () => [
  myApi1.util.resetApiState(),
  myApi2.util.resetApiState(),
];

resetCache = () => {
  for (const x of getResetApiActions())
    store.dispatch(x);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions