@@ -635,5 +635,32 @@ describe('api_client', () => {
635635
636636 expect ( secondRequest . getHeader ( requestIdHeader ) ) . to . deep . equal ( 'second-random-uuid,first-existing-request-id,second-existing-request-id,random-uuid' )
637637 } )
638+
639+ test
640+ . it ( 'resets request id when it exceeds 7KB' , async ctx => {
641+ const cmd = new Command ( [ ] , ctx . config )
642+ // Create a large request ID that exceeds 7KB
643+ const largeRequestId = 'x' . repeat ( 1024 * 8 )
644+ Reflect . set ( RequestId , 'ids' , [ largeRequestId ] )
645+
646+ generateStub . returns ( 'new-uuid-after-reset' )
647+ api = nock ( 'https://api.heroku.com' ) . get ( '/apps' ) . reply ( 200 , [ { name : 'myapp' } ] )
648+
649+ const { request} = await cmd . heroku . get ( '/apps' )
650+ expect ( request . getHeader ( requestIdHeader ) ) . to . deep . equal ( [ 'new-uuid-after-reset' ] )
651+ } )
652+
653+ test
654+ . it ( 'keeps existing request id when under 7KB' , async ctx => {
655+ const cmd = new Command ( [ ] , ctx . config )
656+ // Create a request ID that's under 7KB
657+ const normalRequestId = 'normal-request-id'
658+ Reflect . set ( RequestId , 'ids' , [ normalRequestId ] )
659+
660+ api = nock ( 'https://api.heroku.com' ) . get ( '/apps' ) . reply ( 200 , [ { name : 'myapp' } ] )
661+
662+ const { request} = await cmd . heroku . get ( '/apps' )
663+ expect ( request . getHeader ( requestIdHeader ) ) . to . deep . equal ( ',normal-request-id' )
664+ } )
638665 } )
639666} )
0 commit comments