Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
'node/global-require': 0,
'promise/no-callback-in-promise': 0,
'promise/prefer-await-to-callbacks': 0,
'promise/prefer-await-to-then': 0,
'unicorn/filename-case': 0,
},
overrides: [...overrides],
Expand Down
12 changes: 7 additions & 5 deletions src/deploy/hasher-segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ const { normalizePath } = require('./util')
const hasherCtor = ({ concurrentHash, hashAlgorithm = 'sha1' }) => {
const hashaOpts = { algorithm: hashAlgorithm }
if (!concurrentHash) throw new Error('Missing required opts')
return transform(concurrentHash, { objectMode: true }, (fileObj, cb) => {
hasha
.fromFile(fileObj.filepath, hashaOpts)
return transform(concurrentHash, { objectMode: true }, async (fileObj, cb) => {
try {
const hash = await hasha.fromFile(fileObj.filepath, hashaOpts)
// insert hash and asset type to file obj
.then((hash) => cb(null, { ...fileObj, hash }))
.catch((error) => cb(error))
return cb(null, { ...fileObj, hash })
} catch (error) {
return cb(error)
}
})
}

Expand Down
29 changes: 13 additions & 16 deletions src/deploy/upload-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,19 @@ const retryUpload = (uploadFn, maxRetry) =>
maxDelay: 90000,
})

const tryUpload = () => {
uploadFn()
.then((results) => resolve(results))
.catch((error) => {
lastError = error
switch (true) {
// observed errors: 408, 401 (4** swallowed), 502
case error.status >= 400:
case error.name === 'FetchError': {
return fibonacciBackoff.backoff()
}
default: {
return reject(error)
}
}
})
const tryUpload = async () => {
try {
const results = await uploadFn()
return resolve(results)
} catch (error) {
lastError = error
// observed errors: 408, 401 (4** swallowed), 502
if (error.status >= 400 || error.name === 'FetchError') {
fibonacciBackoff.backoff()
return
}
return reject(error)
}
}

fibonacciBackoff.failAfter(maxRetry)
Expand Down