@@ -1160,6 +1160,8 @@ export class LRUCache {
11601160 const cb = ( v , updateCache = false ) => {
11611161 const { aborted } = ac . signal ;
11621162 const ignoreAbort = options . ignoreFetchAbort && v !== undefined ;
1163+ const proceed = options . ignoreFetchAbort ||
1164+ ! ! ( options . allowStaleOnFetchAbort && v !== undefined ) ;
11631165 if ( options . status ) {
11641166 if ( aborted && ! updateCache ) {
11651167 options . status . fetchAborted = true ;
@@ -1172,7 +1174,7 @@ export class LRUCache {
11721174 }
11731175 }
11741176 if ( aborted && ! ignoreAbort && ! updateCache ) {
1175- return fetchFail ( ac . signal . reason ) ;
1177+ return fetchFail ( ac . signal . reason , proceed ) ;
11761178 }
11771179 // either we didn't abort, and are still here, or we did, and ignored
11781180 const bf = p ;
@@ -1202,9 +1204,10 @@ export class LRUCache {
12021204 options . status . fetchRejected = true ;
12031205 options . status . fetchError = er ;
12041206 }
1205- return fetchFail ( er ) ;
1207+ // do not pass go, do not collect $200
1208+ return fetchFail ( er , false ) ;
12061209 } ;
1207- const fetchFail = ( er ) => {
1210+ const fetchFail = ( er , proceed ) => {
12081211 const { aborted } = ac . signal ;
12091212 const allowStaleAborted = aborted && options . allowStaleOnFetchAbort ;
12101213 const allowStale = allowStaleAborted || options . allowStaleOnFetchRejection ;
@@ -1213,7 +1216,8 @@ export class LRUCache {
12131216 if ( this . #valList[ index ] === p ) {
12141217 // if we allow stale on fetch rejections, then we need to ensure that
12151218 // the stale value is not removed from the cache when the fetch fails.
1216- const del = ! noDelete || bf . __staleWhileFetching === undefined ;
1219+ const del = ! noDelete ||
1220+ ! proceed && bf . __staleWhileFetching === undefined ;
12171221 if ( del ) {
12181222 this . #delete( k , 'fetch' ) ;
12191223 }
0 commit comments