Skip to content

Commit

Permalink
add a retry on migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 8, 2023
1 parent fd4c745 commit 375d44d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/pds/src/migrate-script/migrate-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
makeAdminHeaders,
repairBlob,
repairFailedPrefs,
retryOnce,
transferPreferences,
} from './util'

Expand Down Expand Up @@ -66,7 +67,9 @@ export const runScript = async () => {
}
migrateQueue.add(async () => {
try {
await migrateRepo(ctx, db, pdsInfo, status, adminHeaders)
await retryOnce(() =>
migrateRepo(ctx, db, pdsInfo, status, adminHeaders),
)
await db
.updateTable('status')
.set({ failed: 0, err: null })
Expand Down
8 changes: 8 additions & 0 deletions packages/pds/src/migrate-script/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export const makeAdminHeaders = (secrets: ServerSecrets): AdminHeaders => {
}
}

export const retryOnce = async (fn: () => Promise<unknown>) => {
try {
await fn()
} catch {
await fn()
}
}

export const repairFailedPrefs = async (
ctx: AppContext,
db: MigrateDb,
Expand Down

0 comments on commit 375d44d

Please sign in to comment.