diff --git a/packages/pds/src/migrate-script/migrate-all.ts b/packages/pds/src/migrate-script/migrate-all.ts index 37a9a0963ed..e89257fb815 100644 --- a/packages/pds/src/migrate-script/migrate-all.ts +++ b/packages/pds/src/migrate-script/migrate-all.ts @@ -9,6 +9,7 @@ import PQueue from 'p-queue' import { AdminHeaders, PdsInfo, + checkBorked, getPds, getUserAccount, repairBlob, @@ -81,6 +82,9 @@ export const runScript = async () => { .where('did', '=', status.did) .execute() failed++ + + // check if the did is caught in a bad state where migration failed but plc got updated + await checkBorked(ctx, status.did) } if (completed % 5 === 0) { console.log(`completed: ${completed}, failed: ${failed}`) diff --git a/packages/pds/src/migrate-script/util.ts b/packages/pds/src/migrate-script/util.ts index 05e402f3909..9005bef9196 100644 --- a/packages/pds/src/migrate-script/util.ts +++ b/packages/pds/src/migrate-script/util.ts @@ -1,3 +1,4 @@ +import fs from 'fs/promises' import dotenv from 'dotenv' import axios from 'axios' import * as ui8 from 'uint8arrays' @@ -298,3 +299,15 @@ const logFailedTakedown = async (db: MigrateDb, takedown: FailedTakedown) => { .onConflict((oc) => oc.doNothing()) .execute() } + +export const checkBorked = async (ctx: AppContext, did: string) => { + try { + const data = await ctx.plcClient.getDocumentData(did) + const endpoint = data.services['atproto_pds'].endpoint + if (endpoint !== 'https://bsky.social') { + await fs.appendFile('borked_dids.tx', `${did}\n`) + } + } catch { + // noop + } +}