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({
236
236
237
237
meta . response = responseClone
238
238
239
- let resultData
239
+ let resultData : any
240
+ let responseText : string = ''
240
241
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
242
256
} catch ( e ) {
243
257
return {
244
258
error : {
245
259
status : 'PARSING_ERROR' ,
246
260
originalStatus : response . status ,
247
- data : await responseClone . clone ( ) . text ( ) ,
261
+ data : responseText ,
248
262
error : String ( e ) ,
249
263
} ,
250
264
meta,
You can’t perform that action at this time.
0 commit comments