@@ -260,6 +260,31 @@ describe('HttpClient error mapping', () => {
260260 expect ( fetchImpl ) . toHaveBeenCalledTimes ( 4 ) ;
261261 } ) ;
262262
263+ it ( 'does not retry transport errors for keyless writes' , async ( ) => {
264+ const fetchImpl = vi . fn ( async ( ) => {
265+ throw new Error ( 'ECONNRESET' ) ;
266+ } ) ;
267+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
268+ await expect ( client . post ( '/projects' , { body : { name : 'Checkout' } } ) ) . rejects . toBeInstanceOf (
269+ TransportError ,
270+ ) ;
271+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 1 ) ;
272+ } ) ;
273+
274+ it ( 'retries transport errors for writes with an idempotency key' , async ( ) => {
275+ const fetchImpl = vi . fn ( async ( ) => {
276+ throw new Error ( 'ECONNRESET' ) ;
277+ } ) ;
278+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
279+ await expect (
280+ client . post ( '/projects' , {
281+ body : { name : 'Checkout' } ,
282+ headers : { 'Idempotency-Key' : 'op_123' } ,
283+ } ) ,
284+ ) . rejects . toBeInstanceOf ( TransportError ) ;
285+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 4 ) ;
286+ } ) ;
287+
263288 it ( 'does not retry AbortError' , async ( ) => {
264289 const fetchImpl = vi . fn ( async ( ) => {
265290 const err = new Error ( 'aborted' ) ;
@@ -331,6 +356,27 @@ describe('HttpClient transport-edge statuses', () => {
331356 } ,
332357 ) ;
333358
359+ it ( 'does not retry bare transport-edge responses for keyless writes' , async ( ) => {
360+ const fetchImpl = vi . fn ( async ( ) => new Response ( 'proxy gateway html' , { status : 502 } ) ) ;
361+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
362+ await expect ( client . post ( '/projects' , { body : { name : 'Checkout' } } ) ) . rejects . toBeInstanceOf (
363+ TransportError ,
364+ ) ;
365+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 1 ) ;
366+ } ) ;
367+
368+ it ( 'retries bare transport-edge responses for writes with an idempotency key' , async ( ) => {
369+ const fetchImpl = vi . fn ( async ( ) => new Response ( 'proxy gateway html' , { status : 502 } ) ) ;
370+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
371+ await expect (
372+ client . post ( '/projects' , {
373+ body : { name : 'Checkout' } ,
374+ headers : { 'idempotency-key' : 'op_123' } ,
375+ } ) ,
376+ ) . rejects . toBeInstanceOf ( TransportError ) ;
377+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 4 ) ;
378+ } ) ;
379+
334380 it ( '502 carrying our envelope still maps to its catalog code' , async ( ) => {
335381 const body = {
336382 error : {
0 commit comments