File tree 1 file changed +17
-3
lines changed
packages/toolkit/src/query
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -229,16 +229,30 @@ export function fetchBaseQuery({
229
229
230
230
meta . response = responseClone
231
231
232
- let resultData
232
+ let resultData : any
233
+ let responseText : string = ''
233
234
try {
234
- resultData = await handleResponse ( response , responseHandler )
235
+ let handleResponseError
236
+ await Promise . all ( [
237
+ handleResponse ( response , responseHandler ) . then (
238
+ ( r ) => ( resultData = r ) ,
239
+ ( e ) => ( handleResponseError = e )
240
+ ) ,
241
+ // see https://github.com/node-fetch/node-fetch/issues/665#issuecomment-538995182
242
+ // we *have* to "use up" both streams at the same time or they will stop running in node-fetch scenarios
243
+ responseClone . text ( ) . then (
244
+ ( r ) => ( responseText = r ) ,
245
+ ( ) => { }
246
+ ) ,
247
+ ] )
248
+ if ( handleResponseError ) throw handleResponseError
235
249
} catch ( e ) {
236
250
return {
237
251
error : {
238
252
status : 'PARSING_ERROR' ,
239
253
originalStatus : response . status ,
240
254
statusText : response . statusText ,
241
- data : await responseClone . clone ( ) . text ( ) ,
255
+ data : responseText ,
242
256
error : String ( e ) ,
243
257
} ,
244
258
meta,
You can’t perform that action at this time.
0 commit comments