···149149150150 let pds_url = service.service_endpoint;
151151152152- // in theory, we can use com.atproto.identity.resolveHandle against a PDS, but that seems
153153- // like a way to end up with really sus handles.
154154- let Some(handle_did) = inner.resolver.resolve_handle(&handle).await? else {
155155- eyre::bail!("Failed to resolve did for handle {handle}");
156156- };
157157-158158- if handle_did != did {
159159- eyre::bail!("requested DID doesn't match handle");
160160- }
161161-162162- // set the handle from above
163163- db::update_handle(conn, did, Some(handle)).await?;
164164-165165- // check the repo status
152152+ // check the repo status before we attempt to resolve the handle. There's a case where we can't
153153+ // resolve the handle in the DID doc because the acc is already deleted.
166154 let Some(repo_status) = check_pds_repo_status(&inner.client, &pds_url, did).await? else {
167155 // this repo can't be found - set dirty and assume deleted.
168156 tracing::debug!("repo was deleted");
···178166 db::update_actor_status(conn, did, status.into(), ActorSyncState::Dirty).await?;
179167 return Ok(());
180168 }
169169+170170+ // at this point, the account will be active and we can attempt to resolve the handle.
171171+172172+ // in theory, we can use com.atproto.identity.resolveHandle against a PDS, but that seems
173173+ // like a way to end up with really sus handles.
174174+ let Some(handle_did) = inner.resolver.resolve_handle(&handle).await? else {
175175+ eyre::bail!("Failed to resolve did for handle {handle}");
176176+ };
177177+178178+ if handle_did != did {
179179+ eyre::bail!("requested DID doesn't match handle");
180180+ }
181181+182182+ // set the handle from above
183183+ db::update_handle(conn, did, Some(handle)).await?;
181184182185 // now we can start actually backfilling
183186 db::update_repo_sync_state(conn, did, ActorSyncState::Processing).await?;