kit
kit copied to clipboard
Abort Stale Invalidation Request
Describe the problem
Consider the scenario where several invalidate requests to the same dependency are triggered in rapid succession (say because of an updating query parameter, e.g. ?search=foo
).
The order in which these requests return from the server is not guaranteed, which means it's possible that the last resolving revalidation will be stale.
Describe the proposed solution
I wonder if we allow an optional abort signal, where AbortSignal
implements the canonical Abort API.
function invalidate(
dependency: string | ((href: string) => boolean)
options?: { signal?: AbortSignal }
): Promise<void>;
Alternatives considered
Sveltekit's invalidate function could manage this automatically, but I worry there are scenarios where one might need multiple inflight invalidation requests.
Importance
would make my life easier
Additional Information
As always, thanks so much for all the great work! Sveltekit is such a gamechanger for NYTs!