File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
packages/toolkit/src/query Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -236,15 +236,29 @@ export function fetchBaseQuery({
236236
237237 meta . response = responseClone
238238
239- let resultData
239+ let resultData : any
240+ let responseText : string = ''
240241 try {
241- resultData = await handleResponse ( response , responseHandler )
242+ let handleResponseError
243+ await Promise . all ( [
244+ handleResponse ( response , responseHandler ) . then (
245+ ( r ) => ( resultData = r ) ,
246+ ( e ) => ( handleResponseError = e )
247+ ) ,
248+ // see https://github.com/node-fetch/node-fetch/issues/665#issuecomment-538995182
249+ // we *have* to "use up" both streams at the same time or they will stop running in node-fetch scenarios
250+ responseClone . text ( ) . then (
251+ ( r ) => ( responseText = r ) ,
252+ ( ) => { }
253+ ) ,
254+ ] )
255+ if ( handleResponseError ) throw handleResponseError
242256 } catch ( e ) {
243257 return {
244258 error : {
245259 status : 'PARSING_ERROR' ,
246260 originalStatus : response . status ,
247- data : await responseClone . clone ( ) . text ( ) ,
261+ data : responseText ,
248262 error : String ( e ) ,
249263 } ,
250264 meta,
You can’t perform that action at this time.
0 commit comments