Skip to content

Commit

Permalink
save borked
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 10, 2023
1 parent eb92915 commit 5976564
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/pds/src/migrate-script/migrate-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import PQueue from 'p-queue'
import {
AdminHeaders,
PdsInfo,
checkBorked,
getPds,
getUserAccount,
repairBlob,
Expand Down Expand Up @@ -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}`)
Expand Down
13 changes: 13 additions & 0 deletions packages/pds/src/migrate-script/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fs from 'fs/promises'
import dotenv from 'dotenv'
import axios from 'axios'
import * as ui8 from 'uint8arrays'
Expand Down Expand Up @@ -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
}
}

0 comments on commit 5976564

Please sign in to comment.