@@ -113,6 +113,30 @@ describe('EdgeFeatureStore', () => {
113113 } ) ;
114114 } ) ;
115115
116+ describe ( 'load caching' , ( ) => {
117+ it ( 'does not cache a rejected load and retries on the next call' , async ( ) => {
118+ mockGet . mockRejectedValueOnce ( new Error ( 'transient KV error' ) ) ;
119+
120+ // The first read hits the transient error and falls back to null.
121+ const first = await asyncFeatureStore . get ( { namespace : 'features' } , 'testFlag1' ) ;
122+ expect ( first ) . toBeNull ( ) ;
123+
124+ // A later read must retry the provider (the beforeEach success impl) rather
125+ // than reuse the cached rejected promise, and should succeed.
126+ const second = await asyncFeatureStore . get ( { namespace : 'features' } , 'testFlag1' ) ;
127+ expect ( second ) . toMatchObject ( testData . flags . testFlag1 ) ;
128+ expect ( mockGet ) . toHaveBeenCalledTimes ( 2 ) ;
129+ } ) ;
130+
131+ it ( 'caches a successful load and reuses it across calls' , async ( ) => {
132+ await asyncFeatureStore . get ( { namespace : 'features' } , 'testFlag1' ) ;
133+ await asyncFeatureStore . get ( { namespace : 'segments' } , 'testSegment1' ) ;
134+ await asyncFeatureStore . all ( { namespace : 'features' } ) ;
135+
136+ expect ( mockGet ) . toHaveBeenCalledTimes ( 1 ) ;
137+ } ) ;
138+ } ) ;
139+
116140 describe ( 'init & getDescription' , ( ) => {
117141 it ( 'can initialize' , ( done ) => {
118142 const cb = jest . fn ( ( ) => {
0 commit comments