[3.x] Already-aborted requests are still sent by the XHR client
Inertia adapter(s) affected
- React
- Vue 3
- Svelte
- Not Applicable
JS package version
3.7.1 (@inertiajs/core, @inertiajs/react, @inertiajs/vue3, and @inertiajs/svelte). Also reproduced on 3.x at 01a06f7c653f469a94f254e89587d1bddfa913bf.
Backend stack (optional)
The reproduction uses the repository's shared Node.js test server. The failure occurs in the browser's default XHR client and does not depend on a specific backend framework.
Describe the problem
The default XHR client sends a request even when its AbortSignal is already aborted before the XHR is created. The client registers an abort listener, but an earlier abort event does not fire again.
Expected: reject with HttpCancelledError without sending the request.
Actual: send the request. A cancelled visit can still receive a successful response and replace newer page data. This also occurs when cancellation happens during an asynchronous HTTP request handler. Cancellation after XHR starts is a separate path and already works.
Steps to reproduce
In an initialized Inertia application, use the default HTTP client with any valid same-origin endpoint:
import { http } from '@inertiajs/core'
const controller = new AbortController()
controller.abort()
await http.getClient().request({
method: 'get',
url: '/existing-endpoint',
signal: controller.signal,
})- Open the browser's Network panel.
- Run the code with an existing GET endpoint.
- Observe that the browser sends the request instead of rejecting it as cancelled.
The regression tests also cover cancellation during asynchronous request preparation, cancellation after XHR starts, a cancelled visit followed by a newer visit, and a cancelled prefetch. On unpatched 3.7.1, the already-aborted signal, asynchronous-preparation, cancelled-visit, and cancelled-prefetch regressions fail; ordinary cancellation after network start passes.
Source: inertiajs/inertia