Skip to content

Commit

Permalink
Fix latest migration failures (#2227)
Browse files Browse the repository at this point in the history
We've seen a surge of migration failures with the last release which
includes a migration making network requests.

This PR aims at preventing these failures and making sure Sentry
exceptions include more details to help us debug migration errors in the
future.
  • Loading branch information
taratatach authored Apr 27, 2022
2 parents 87a9822 + 72d29a5 commit 4a03b5b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
11 changes: 8 additions & 3 deletions core/migrations/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

const path = require('path')
const { Promise } = require('bluebird')

const metadata = require('../metadata')
const { SCHEMA_INITIAL_VERSION } = require('./constants')
Expand Down Expand Up @@ -352,8 +353,9 @@ module.exports = ([
docs /*: SavedMetadata[] */,
{ remote } /*: InjectedDependencies */
) /*: Promise<SavedMetadata[]> */ => {
return Promise.all(
docs.map(async doc => {
return Promise.map(
docs,
async doc => {
const remoteDir = await remote.remoteCozy.findDir(doc.remote._id)

if (remoteDir != null) {
Expand Down Expand Up @@ -400,7 +402,10 @@ module.exports = ([
}

return doc
})
},
// XXX: Avoid exhausting network resources by limiting the number of
// concurrent requests.
{ concurrency: 10 }
)
}
}
Expand Down
1 change: 0 additions & 1 deletion core/utils/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ const handleBunyanMessage = msg => {
// Send messages explicitly marked for sentry and all TypeError instances
if (msg.sentry || (msg.err && msg.err.name === 'TypeError')) {
const extra = _.omit(msg, [
'err',
'tags',
'v',
'hostname',
Expand Down
2 changes: 1 addition & 1 deletion gui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {
SYNC_DIR_EMPTY_MESSAGE,
SYNC_DIR_UNLINKED_MESSAGE
} = require('../core/local/errors')
const { MigrationFailedError } = require('../core/migrations/migrations')
const { MigrationFailedError } = require('../core/migrations')
const config = require('../core/config')
const winRegistry = require('../core/utils/win_registry')

Expand Down

0 comments on commit 4a03b5b

Please sign in to comment.