fix(cancellable): suppress non-Abort errors from superseded predecessors (0.87.24)
CancellableLoader.run() previously swallowed AbortError but propagated every other rejection. A predecessor whose fetch survived its abort (timing race, or fn that ignores signal) and then 5xx'd would bubble the error into the caller's catch, clearing the successor's spinner and writing its `error` field — exactly the flicker the loader was supposed to prevent. Strengthen the contract: a call that no longer owns this.current returns null regardless of how it died. Symmetric with the existing late-resolve suppression at the success path. The loadCoverage catch in admin/analysis/+page.svelte now only fires when this call genuinely failed AND still owns the loader — so clearing the spinner there is sound. Three new unit tests pin all three contract corners: a superseded predecessor's non-Abort rejection resolves to null; a standalone call with no successor still throws normally; the AbortError swallow on a still-owning call (synthetic AbortError from fn with no successor or cancel()) remains protected, since the new supersede check would otherwise have eaten every existing AbortError-path test and left that branch as silently-removable dead code. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -369,11 +369,12 @@
|
||||
loading = false;
|
||||
loadingMore = false;
|
||||
} catch (e) {
|
||||
// Reaching this catch means run() rejected for a call
|
||||
// that still owned the loader — a superseded call would
|
||||
// have returned null instead (CancellableLoader contract,
|
||||
// 0.87.24). So this call genuinely failed and is allowed
|
||||
// to surface its error / clear the spinner.
|
||||
error = e instanceof ApiError ? e.message : 'Failed to load coverage.';
|
||||
// Non-Abort error: this call genuinely failed and OWNS
|
||||
// (any successor would have flipped run() to null before
|
||||
// throwing). Clear the spinner so the error message is
|
||||
// readable.
|
||||
loading = false;
|
||||
loadingMore = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user