Skip to content

BUG | useAxios | Issue with useAxios when Calling execute Multiple Times #4357

@LongGGEZ

Description

Describe the bug

When using useAxios from the VueUse library to make multiple HTTP requests, a common issue occurs when the execute method is called repeatedly in quick succession. The useAxios hook prioritizes the last request, but instead of returning a success response, it returns a cancel error for the last executed request.

This is problematic when you expect the final request to complete successfully, but it incorrectly throws an error due to cancellation, even though the request was actually executed and processed correctly.

Screenshot 2024-11-23 at 03 21 00 Screenshot 2024-11-23 at 03 21 47

Expected Behavior:
The expectation is that useAxios should not throw a cancellation error for the final request if it has been executed successfully. Instead, it should return the actual result of the request.

Reproduction

https://codesandbox.io/p/sandbox/t5287m?file=%2Fsrc%2Fcomponents%2FHelloWorld.vue

System Info

System:
    OS: macOS 15.1
    CPU: (8) arm64 Apple M3
    Memory: 100.56 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.15.1/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v20.15.1/bin/npm
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 18.1
  npmPackages:
    @vueuse/core: ^10.11.1 => 10.11.1 
    @vueuse/integrations: ^10.11.1 => 10.11.1 
    vue: ^3.4.37 => 3.4.38

Used Package Manager

yarn

Validations

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions