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>(
229229 }
230230 }
231231
232- const jsonBody = await response . json ( ) ;
232+ const jsonBody = await safeJsonFromResponse ( response ) ;
233233 const parsedResult = schema . safeParse ( jsonBody ) ;
234234
235235 if ( parsedResult . success ) {
@@ -269,6 +269,14 @@ async function _doZodFetchWithRetries<TResponseBodySchema extends z.ZodTypeAny>(
269269 }
270270}
271271
272+ async function safeJsonFromResponse ( response : Response ) : Promise < any > {
273+ try {
274+ return await response . clone ( ) . json ( ) ;
275+ } catch ( error ) {
276+ return ;
277+ }
278+ }
279+
272280function castToError ( err : any ) : Error {
273281 if ( err instanceof Error ) return err ;
274282 return new Error ( err ) ;
You can’t perform that action at this time.
0 commit comments