File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/core/src/v3/apiClient Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -229,7 +229,7 @@ async function _doZodFetchWithRetries<TResponseBodySchema extends z.ZodTypeAny>(
229
229
}
230
230
}
231
231
232
- const jsonBody = await response . json ( ) ;
232
+ const jsonBody = await safeJsonFromResponse ( response ) ;
233
233
const parsedResult = schema . safeParse ( jsonBody ) ;
234
234
235
235
if ( parsedResult . success ) {
@@ -269,6 +269,14 @@ async function _doZodFetchWithRetries<TResponseBodySchema extends z.ZodTypeAny>(
269
269
}
270
270
}
271
271
272
+ async function safeJsonFromResponse ( response : Response ) : Promise < any > {
273
+ try {
274
+ return await response . clone ( ) . json ( ) ;
275
+ } catch ( error ) {
276
+ return ;
277
+ }
278
+ }
279
+
272
280
function castToError ( err : any ) : Error {
273
281
if ( err instanceof Error ) return err ;
274
282
return new Error ( err ) ;
You can’t perform that action at this time.
0 commit comments