@@ -328,6 +328,31 @@ describe('HttpClient error mapping', () => {
328328 expect ( fetchImpl ) . toHaveBeenCalledTimes ( 4 ) ;
329329 } ) ;
330330
331+ it ( 'does not retry transport errors for keyless writes' , async ( ) => {
332+ const fetchImpl = vi . fn ( async ( ) => {
333+ throw new Error ( 'ECONNRESET' ) ;
334+ } ) ;
335+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
336+ await expect ( client . post ( '/projects' , { body : { name : 'Checkout' } } ) ) . rejects . toBeInstanceOf (
337+ TransportError ,
338+ ) ;
339+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 1 ) ;
340+ } ) ;
341+
342+ it ( 'retries transport errors for writes with an idempotency key' , async ( ) => {
343+ const fetchImpl = vi . fn ( async ( ) => {
344+ throw new Error ( 'ECONNRESET' ) ;
345+ } ) ;
346+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
347+ await expect (
348+ client . post ( '/projects' , {
349+ body : { name : 'Checkout' } ,
350+ headers : { 'Idempotency-Key' : 'op_123' } ,
351+ } ) ,
352+ ) . rejects . toBeInstanceOf ( TransportError ) ;
353+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 4 ) ;
354+ } ) ;
355+
331356 it ( 'does not retry AbortError' , async ( ) => {
332357 const fetchImpl = vi . fn ( async ( ) => {
333358 const err = new Error ( 'aborted' ) ;
@@ -399,6 +424,27 @@ describe('HttpClient transport-edge statuses', () => {
399424 } ,
400425 ) ;
401426
427+ it ( 'does not retry bare transport-edge responses for keyless writes' , async ( ) => {
428+ const fetchImpl = vi . fn ( async ( ) => new Response ( 'proxy gateway html' , { status : 502 } ) ) ;
429+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
430+ await expect ( client . post ( '/projects' , { body : { name : 'Checkout' } } ) ) . rejects . toBeInstanceOf (
431+ TransportError ,
432+ ) ;
433+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 1 ) ;
434+ } ) ;
435+
436+ it ( 'retries bare transport-edge responses for writes with an idempotency key' , async ( ) => {
437+ const fetchImpl = vi . fn ( async ( ) => new Response ( 'proxy gateway html' , { status : 502 } ) ) ;
438+ const client = makeClient ( fetchImpl as unknown as typeof fetch ) ;
439+ await expect (
440+ client . post ( '/projects' , {
441+ body : { name : 'Checkout' } ,
442+ headers : { 'idempotency-key' : 'op_123' } ,
443+ } ) ,
444+ ) . rejects . toBeInstanceOf ( TransportError ) ;
445+ expect ( fetchImpl ) . toHaveBeenCalledTimes ( 4 ) ;
446+ } ) ;
447+
402448 it ( '502 carrying our envelope still maps to its catalog code' , async ( ) => {
403449 const body = {
404450 error : {
0 commit comments