11import type { HttpClientResponse } from "@effect/platform"
2- import { FetchHttpClient , HttpBody , HttpClient } from "@effect/platform"
2+ import { HttpBody , HttpClient } from "@effect/platform"
33import type * as HttpClientError from "@effect/platform/HttpClientError"
4+ import { NodeHttpClient } from "@effect/platform-node"
45import { Effect } from "effect"
56
67import { readHttpResponseTextStream } from "../shared/http-response-stream.js"
@@ -140,16 +141,19 @@ const executeRequestWithControllerRetry = (
140141 body : JsonRequest | undefined
141142) => {
142143 const execute = ( ) => executeRequest ( client , resolveApiBaseUrl ( ) , method , path , body )
144+ const shouldRetry = method === "GET"
143145
144146 return execute ( ) . pipe (
145147 Effect . matchEffect ( {
146148 onFailure : ( error ) =>
147- ensureControllerReady ( ) . pipe (
148- Effect . matchEffect ( {
149- onFailure : ( ) => Effect . fail ( error ) ,
150- onSuccess : ( ) => execute ( )
151- } )
152- ) ,
149+ ! shouldRetry
150+ ? Effect . fail ( error )
151+ : ensureControllerReady ( ) . pipe (
152+ Effect . matchEffect ( {
153+ onFailure : ( ) => Effect . fail ( error ) ,
154+ onSuccess : ( ) => execute ( )
155+ } )
156+ ) ,
153157 onSuccess : ( value ) => Effect . succeed ( value )
154158 } )
155159 )
@@ -198,7 +202,7 @@ export const request = (
198202 }
199203
200204 return parsed
201- } ) . pipe ( Effect . provide ( FetchHttpClient . layer ) , mapTransportError ( method , path ) )
205+ } ) . pipe ( Effect . provide ( NodeHttpClient . layer ) , mapTransportError ( method , path ) )
202206
203207export const requestVoid = ( method : ApiHttpMethod , path : string , body ?: JsonRequest ) =>
204208 request ( method , path , body ) . pipe ( Effect . asVoid )
@@ -219,4 +223,4 @@ export const requestTextStream = (
219223 }
220224
221225 return yield * _ ( readHttpResponseTextStream ( response , onChunk ) )
222- } ) . pipe ( Effect . provide ( FetchHttpClient . layer ) , mapTransportError ( method , path ) )
226+ } ) . pipe ( Effect . provide ( NodeHttpClient . layer ) , mapTransportError ( method , path ) )
0 commit comments