File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed
Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,7 @@ function getCachedValuePromise(
5555 flagKey : string ,
5656 entitiesKey : string ,
5757) : any {
58- const map = evaluationCache . get ( headers ) ?. get ( flagKey ) ;
59- if ( ! map ) return undefined ;
60- return map . get ( entitiesKey ) ;
58+ return evaluationCache . get ( headers ) ?. get ( flagKey ) ?. get ( entitiesKey ) ;
6159}
6260
6361function setCachedValuePromise (
@@ -260,17 +258,23 @@ function getRun<ValueType, EntitiesType>(
260258 dedupeCacheKey = headersStore ;
261259 }
262260
263- const overrides = await getOverrides (
264- readonlyCookies . get ( 'vercel-flag-overrides' ) ?. value ,
265- ) ;
261+ // skip microtask if cookie does not exist or is empty
262+ const override = readonlyCookies . get ( 'vercel-flag-overrides' ) ?. value ;
263+ const overrides =
264+ typeof override === 'string' && override !== ''
265+ ? await getOverrides ( override )
266+ : null ;
266267
267268 // the flag is being used in app router
268- const entities = ( await getEntities (
269- options . identify ,
270- dedupeCacheKey ,
271- readonlyHeaders ,
272- readonlyCookies ,
273- ) ) as EntitiesType | undefined ;
269+ // skip microtask if identify does not exist
270+ const entities = options . identify
271+ ? ( ( await getEntities (
272+ options . identify ,
273+ dedupeCacheKey ,
274+ readonlyHeaders ,
275+ readonlyCookies ,
276+ ) ) as EntitiesType | undefined )
277+ : undefined ;
274278
275279 // check cache
276280 const entitiesKey = JSON . stringify ( entities ) ?? '' ;
You can’t perform that action at this time.
0 commit comments