@@ -258,26 +258,24 @@ export class AmazonS3Client {
258258 getSuccessResult : ( ) => T | Promise < T > ,
259259 cleanup ?: ( ) => void
260260 ) : Promise < RetryableRequestResponse < T | undefined > > {
261- if ( response . ok ) {
261+ const { ok, status, statusText } = response ;
262+ if ( ok ) {
262263 return {
263264 hasNetworkError : false ,
264265 response : await getSuccessResult ( )
265266 } ;
266- } else if ( response . status === 404 ) {
267+ } else if ( status === 404 ) {
267268 cleanup ?.( ) ;
268269 return {
269270 hasNetworkError : false ,
270271 response : undefined
271272 } ;
272- } else if (
273- ( response . status === 400 || response . status === 401 || response . status === 403 ) &&
274- ! this . _credentials
275- ) {
273+ } else if ( ( status === 400 || status === 401 || status === 403 ) && ! this . _credentials ) {
276274 cleanup ?.( ) ;
277275 // unauthorized due to not providing credentials,
278276 // silence error for better DX when e.g. running locally without credentials
279277 this . _writeWarningLine (
280- `No credentials found and received a ${ response . status } ` ,
278+ `No credentials found and received a ${ status } ` ,
281279 ' response code from the cloud storage.' ,
282280 ' Maybe run rush update-cloud-credentials' ,
283281 ' or set the RUSH_BUILD_CACHE_CREDENTIAL env'
@@ -286,14 +284,14 @@ export class AmazonS3Client {
286284 hasNetworkError : false ,
287285 response : undefined
288286 } ;
289- } else if ( response . status === 400 || response . status === 401 || response . status === 403 ) {
287+ } else if ( status === 400 || status === 401 || status === 403 ) {
290288 cleanup ?.( ) ;
291- throw new Error ( `Amazon S3 responded with status code ${ response . status } (${ response . statusText } )` ) ;
289+ throw new Error ( `Amazon S3 responded with status code ${ status } (${ statusText } )` ) ;
292290 } else {
293291 cleanup ?.( ) ;
294292 return {
295293 hasNetworkError : true ,
296- error : new Error ( `Amazon S3 responded with status code ${ response . status } (${ response . statusText } )` )
294+ error : new Error ( `Amazon S3 responded with status code ${ status } (${ statusText } )` )
297295 } ;
298296 }
299297 }
0 commit comments