@@ -128,8 +128,6 @@ export default class HttpClient implements ProtocolClient {
128128
129129 const result = await this . doFetch ( request ) ;
130130
131- this . checkFetchResponse ( result ) ;
132-
133131 debug ( `HttpClient received headers: ${ JSON . stringify ( result . headers . raw ( ) ) } ` ) ;
134132 debug ( `HttpClient received Content-Type: ${ result . headers . get ( "content-type" ) } ` ) ;
135133
@@ -154,8 +152,6 @@ export default class HttpClient implements ProtocolClient {
154152
155153 debug ( `HttpClient received ${ result . status } from ${ result . url } ` ) ;
156154
157- this . checkFetchResponse ( result ) ;
158-
159155 debug ( `HttpClient received headers: ${ JSON . stringify ( result . headers . raw ( ) ) } ` ) ;
160156 }
161157
@@ -218,8 +214,6 @@ export default class HttpClient implements ProtocolClient {
218214 debug ( `HttpClient received ${ result . status } from ${ request . url } ` ) ;
219215 debug ( `HttpClient received Content-Type: ${ result . headers . get ( "content-type" ) } ` ) ;
220216
221- this . checkFetchResponse ( result ) ;
222-
223217 // in browsers node-fetch uses the native fetch, which returns a ReadableStream
224218 // not complaint with node. Therefore we have to force the conversion here.
225219 const body = ProtocolHelpers . toNodeStream ( result . body as Readable ) ;
@@ -432,9 +426,13 @@ export default class HttpClient implements ProtocolClient {
432426
433427 if ( HttpClient . isOAuthTokenExpired ( result , this . credential ) ) {
434428 this . credential = await ( this . credential as OAuthCredential ) . refreshToken ( ) ;
435- return await this . _fetch ( await this . credential . sign ( request ) ) ;
429+ const resultAuth = await this . _fetch ( await this . credential . sign ( request ) ) ;
430+ this . checkFetchResponse ( resultAuth ) ;
431+ return resultAuth ;
436432 }
437433
434+ this . checkFetchResponse ( result ) ;
435+
438436 return result ;
439437 }
440438
0 commit comments