Skip to content

Commit d42cd6f

Browse files
committed
fix: fix cache when request fail
1 parent a8fd7cc commit d42cd6f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/app/cache.service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ export class CacheService {
3939
} else if (fallback && fallback instanceof Observable) {
4040
this.inFlightObservables.set(key, new Subject());
4141
console.log(`%c Calling api for ${key}`, 'color: purple');
42-
return fallback.do((value) => { this.set(key, value, maxAge); });
42+
return fallback
43+
.do((value) => { this.set(key, value, maxAge); })
44+
.catch((err) => {
45+
this.notifyInFlightObservers(key, null);
46+
return Observable.throw(err);
47+
});
4348
} else {
4449
return Observable.throw('Requested key is not available in Cache');
4550
}

0 commit comments

Comments
 (0)