File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,31 @@ describe('createClient', () => {
545545 } ) ;
546546 } ) ;
547547
548+ describe ( 'get(key, { consistentRead: true })' , ( ) => {
549+ it ( 'should handle multiple concurrent requests correctly' , async ( ) => {
550+ const edgeConfig = createClient ( process . env . EDGE_CONFIG ) ;
551+
552+ let i = 0 ;
553+ // Create a more realistic response with a proper body stream
554+ // @ts -expect-error - aaa
555+ fetchMock . mockImplementation ( ( ) => {
556+ return new Response ( JSON . stringify ( `bar${ i ++ } ` ) , {
557+ headers : { 'content-type' : 'application/json' } ,
558+ } ) ;
559+ } ) ;
560+
561+ // Make multiple concurrent requests
562+ const a = edgeConfig . get ( 'foo' , { consistentRead : true } ) ;
563+ const b = edgeConfig . get ( 'foo' , { consistentRead : true } ) ;
564+
565+ await a ;
566+ await b ;
567+ await expect ( a ) . resolves . toEqual ( 'bar0' ) ;
568+ await expect ( b ) . resolves . toEqual ( 'bar1' ) ;
569+ expect ( fetchMock ) . toHaveBeenCalledTimes ( 2 ) ;
570+ } ) ;
571+ } ) ;
572+
548573 describe ( 'has(key)' , ( ) => {
549574 describe ( 'when item exists' , ( ) => {
550575 it ( 'should return true' , async ( ) => {
You can’t perform that action at this time.
0 commit comments