Skip to content

Commit

Permalink
fix(fetch): always call revalidateCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Dec 13, 2022
1 parent dfbbc00 commit 444edc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/fetch/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async function _handleCacheStrategy(options: Required<FetchOptions>): Promise<Re
const fetchedResponsePromise = _handleRemoveDuplicate(options).then((networkResponse) => {
if (networkResponse.ok) {
cacheStorage.put(request, networkResponse.clone());
if (cachedResponse != null && typeof options.revalidateCallback === 'function') {
if (typeof options.revalidateCallback === 'function') {
options.revalidateCallback(networkResponse);
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/fetch/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface FetchOptions extends RequestInit {
/**
* Revalidate callback for `stale_while_revalidate` cache strategy.
*/
revalidateCallback?: (response: Response) => void;
revalidateCallback?: (response: Response) => void | Promise<void>;

/**
* Cache storage custom name.
Expand Down

0 comments on commit 444edc5

Please sign in to comment.