@@ -92,6 +92,8 @@ export async function uploadManifest(
92
92
speed : 0 ,
93
93
} ) ;
94
94
95
+ const errors = [ ] ;
96
+
95
97
await mapLimit (
96
98
filesToUpload ,
97
99
NUM_CONCURRENT_UPLOADS ,
@@ -114,27 +116,38 @@ export async function uploadManifest(
114
116
path : manifestFile . cleanPath ,
115
117
} ,
116
118
} ;
117
- // TODO: Veryify this correctly handles errors and retry attempts.
119
+ // TODO: Verify this correctly handles errors and retry attempts.
118
120
const remotePath = getBlobPath ( manifest . site , manifestFile . hash ) ;
119
- const resp = await storageBucket . upload ( manifestFile . path , {
120
- // NOTE: `gzip: true` must *not* be set here. Doing so interferes
121
- // with the proxied GCS response. Despite not setting `gzip: true`,
122
- // the response remains gzipped from the proxy server.
123
- destination : remotePath ,
124
- metadata : metadata ,
125
- } ) ;
126
- bytesTransferred += parseInt ( resp [ 1 ] . size ) ;
127
- const elapsed = Math . floor ( Date . now ( ) / 1000 ) - startTime ;
128
- const speed = ( bytesTransferred / elapsed / ( 1024 * 1024 ) ) . toFixed ( 2 ) ;
129
- bar . update ( ( numProcessedFiles += 1 ) , {
130
- speed : speed ,
131
- } ) ;
132
- if ( numProcessedFiles === numTotalFiles ) {
133
- bar . stop ( ) ;
121
+ try {
122
+ const resp = await storageBucket . upload ( manifestFile . path , {
123
+ // NOTE: `gzip: true` must *not* be set here. Doing so interferes
124
+ // with the proxied GCS response. Despite not setting `gzip: true`,
125
+ // the response remains gzipped from the proxy server.
126
+ destination : remotePath ,
127
+ metadata : metadata ,
128
+ } ) ;
129
+ bytesTransferred += parseInt ( resp [ 1 ] . size ) ;
130
+ } catch ( err ) {
131
+ errors . push ( err ) ;
132
+ console . error ( `Error uploading -> ${ manifestFile . path } ` ) ;
133
+ console . error ( err ) ;
134
+ } finally {
135
+ const elapsed = Math . floor ( Date . now ( ) / 1000 ) - startTime ;
136
+ const speed = ( bytesTransferred / elapsed / ( 1024 * 1024 ) ) . toFixed ( 2 ) ;
137
+ bar . update ( ( numProcessedFiles += 1 ) , {
138
+ speed : speed ,
139
+ } ) ;
140
+ if ( numProcessedFiles === numTotalFiles ) {
141
+ bar . stop ( ) ;
142
+ }
134
143
}
135
144
} )
136
145
) ;
137
146
147
+ if ( errors . length ) {
148
+ throw new Error ( `Encountered ${ errors . length } errors uploading.` ) ;
149
+ }
150
+
138
151
await finalize ( googleCloudProject , manifest , ttl ) ;
139
152
}
140
153
}
0 commit comments