Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Preserve default API abort behavior during rule reversal

pulse-triage[bot]67f8509e1f87
diff --git a/frontend-modern/src/utils/__tests__/apiClient.org.test.ts b/frontend-modern/src/utils/__tests__/apiClient.org.test.ts
index 6efdcb1f35..1e97870188 100644
--- a/frontend-modern/src/utils/__tests__/apiClient.org.test.ts
+++ b/frontend-modern/src/utils/__tests__/apiClient.org.test.ts
@@ -92,6 +92,18 @@ describe('apiClient org context', () => {
expect(mockFetch).toHaveBeenCalledTimes(1);
});
+ it.each([{ retry: false }, { expectedOrgID: 'default' }])(
+ 'rejects aborted dispatch before fetch for either strict opt-in %j',
+ async (options) => {
+ const controller = new AbortController();
+ controller.abort();
+ await expect(
+ apiFetch('/api/state', { ...options, signal: controller.signal }),
+ ).rejects.toMatchObject({ name: 'AbortError' });
+ expect(mockFetch).not.toHaveBeenCalled();
+ },
+ );
+
it('does not fall back to another authentication method after a strict-session refusal', async () => {
setApiToken('synthetic-token');
setOrgID('tenant-a');
diff --git a/frontend-modern/src/utils/apiClient.ts b/frontend-modern/src/utils/apiClient.ts
index d8b71ce4a6..83d4071688 100644
--- a/frontend-modern/src/utils/apiClient.ts
+++ b/frontend-modern/src/utils/apiClient.ts
@@ -665,7 +665,9 @@ class ApiClient {
// CSRF preparation may have awaited a request while the operator switched
// organisations or left the view. Do not dispatch a stale confirmation.
checkExpectedOrg();
- fetchOptions.signal?.throwIfAborted();
+ // Only strict confirmations opt into the extra pre-dispatch abort check;
+ // ordinary callers retain native fetch's established abort behaviour.
+ if (expectedOrgID !== undefined || !retry) fetchOptions.signal?.throwIfAborted();
let response = await fetch(url, finalOptions);
// Session-preferred reads intentionally omit the API token on their first