Skip to content

Commit

Permalink
fix(fetch): fetchContext duplicate setSignalValue
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Feb 11, 2023
1 parent 66467f6 commit 8aa9b00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/fetch/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function fetchContext(
fetchOption: FetchOptions,
dispatchOptions?: Partial<DispatchOptions>,
): Promise<void> {
logger.logMethodArgs('fetchContext', {contextName});
if (cacheSupported && contextProvider.getValue(contextName) == null) {
try {
fetchOption.cacheStrategy = 'cache_only';
Expand All @@ -58,8 +59,9 @@ export async function fetchContext(
const response = await serviceRequest(fetchOption);
if (
response.meta?.lastUpdated === undefined || // skip lastUpdated check
response.meta?.lastUpdated !== contextProvider.getValue<typeof response>(contextName)?.meta?.reversion
response.meta?.lastUpdated !== contextProvider.getValue<typeof response>(contextName)?.meta?.lastUpdated
) {
logger.logOther('fetchContext:', 'contextProvider.setValue(new-received-context)', {contextName});
contextProvider.setValue<typeof response>(contextName, response, dispatchOptions);
}
}
Expand All @@ -78,7 +80,7 @@ export async function serviceRequest<
>(
options: FetchOptions,
): Promise<AlwatrServiceResponseSuccess<TData> | AlwatrServiceResponseSuccessWithMeta<TData, TMeta>> {
logger.logMethod('serviceRequest');
logger.logMethodArgs('serviceRequest', {url: options.url});

if (isBrowser) {
options.headers ??= {};
Expand Down

0 comments on commit 8aa9b00

Please sign in to comment.