@@ -102,7 +102,7 @@ export default class Evaluator {
102102 const state = new EvalState ( ) ;
103103 const res = await this . evaluateInternal ( flag , context , state , [ ] , eventFactory ) ;
104104 if ( state . bigSegmentsStatus ) {
105- res . detail . reason . bigSegmentsStatus = state . bigSegmentsStatus ;
105+ res . detail . reason = { ... res . detail . reason , bigSegmentsStatus : state . bigSegmentsStatus } ;
106106 }
107107 res . events = state . events ;
108108 return res ;
@@ -465,9 +465,11 @@ export default class Evaluator {
465465 state : EvalState ,
466466 segmentsVisited : string [ ]
467467 ) : Promise < MatchOrError > {
468- const includeExclude = matchSegmentTargets ( segment , context ) ;
469- if ( includeExclude !== undefined ) {
470- return new Match ( includeExclude ) ;
468+ if ( ! segment . unbounded ) {
469+ const includeExclude = matchSegmentTargets ( segment , context ) ;
470+ if ( includeExclude !== undefined ) {
471+ return new Match ( includeExclude ) ;
472+ }
471473 }
472474
473475 let evalResult : EvalResult | undefined ;
@@ -501,6 +503,13 @@ export default class Evaluator {
501503 return this . simpleSegmentMatchContext ( segment , context , state , segmentsVisited ) ;
502504 }
503505
506+ const bigSegmentKind = segment . unboundedContextKind || 'user' ;
507+ const keyForBigSegment = context . key ( bigSegmentKind ) ;
508+
509+ if ( ! keyForBigSegment ) {
510+ return new Match ( false ) ;
511+ }
512+
504513 if ( ! segment . generation ) {
505514 // Big Segment queries can only be done if the generation is known. If it's unset,
506515 // that probably means the data store was populated by an older SDK that doesn't know
@@ -514,13 +523,6 @@ export default class Evaluator {
514523 return new Match ( false ) ;
515524 }
516525
517- const bigSegmentKind = segment . unboundedContextKind || 'user' ;
518- const keyForBigSegment = context . key ( bigSegmentKind ) ;
519-
520- if ( keyForBigSegment === undefined ) {
521- return new Match ( false ) ;
522- }
523-
524526 if ( state . bigSegmentsMembership && state . bigSegmentsMembership [ keyForBigSegment ] ) {
525527 // We've already done the query at some point during the flag evaluation and stored
526528 // the result (if any) in stateOut.bigSegmentsMembership, so we don't need to do it
@@ -572,8 +574,11 @@ export default class Evaluator {
572574 ) : Promise < MatchOrError > {
573575 const segmentRef = makeBigSegmentRef ( segment ) ;
574576 const included = membership ?. [ segmentRef ] ;
575- if ( included ) {
576- return new Match ( true ) ;
577+ // Typically null is not checked because we filter it from the data
578+ // we get in flag updates. Here it is checked because big segment data
579+ // will be contingent on the store that implements it.
580+ if ( included !== undefined && included !== null ) {
581+ return new Match ( included ) ;
577582 }
578583 return this . simpleSegmentMatchContext ( segment , context , state , [ ] ) ;
579584 }
0 commit comments