Replies: 1 comment
-
A ditry workaround on the client is to patch import { actions } from 'astro:actions';
const { signal, abort } = new AbortController();
+ const originalFetch = window.fetch;
+ window.fetch = (input, init) => {
+ init ??= {};
+ init.signal = signal;
+ return originalFetch(input, init);
+};
const result = await actions.search({ query: '123' })
+window.fetch = originalFetch;
setTimeout(abort, 1000) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
It is currently impossible to cancel the call to actions.
Background & Motivation
In some scenarios e.g. typeahead search it is important to cancel already irrelevant calls to the backend. Another scenario would be to cancel a long running task.
Goals
A way to abort the call with AbortController or another way to do it via actions API. Would be also perfect if one can specify additionally a timeout (however having AbortController already gives a way to implement it manually)
Example
Client:
Server:
Beta Was this translation helpful? Give feedback.
All reactions