diff --git a/packages/pds/src/api/com/atproto/sync/subscribeRepos.ts b/packages/pds/src/api/com/atproto/sync/subscribeRepos.ts index 0f98db5061c..7fc9be6f3ac 100644 --- a/packages/pds/src/api/com/atproto/sync/subscribeRepos.ts +++ b/packages/pds/src/api/com/atproto/sync/subscribeRepos.ts @@ -31,7 +31,7 @@ export default function (server: Server, ctx: AppContext) { message: 'Requested cursor exceeded limit. Possibly missing events', } const startEvt = await ctx.sequencer.earliestAfterTime(backfillTime) - outboxCursor = startEvt?.seq ?? undefined + outboxCursor = startEvt?.seq ? startEvt.seq - 1 : undefined } else { outboxCursor = cursor } diff --git a/packages/pds/src/sequencer/sequencer.ts b/packages/pds/src/sequencer/sequencer.ts index 2e0ee59b60f..23624800a41 100644 --- a/packages/pds/src/sequencer/sequencer.ts +++ b/packages/pds/src/sequencer/sequencer.ts @@ -60,9 +60,9 @@ export class Sequencer extends (EventEmitter as new () => SequencerEmitter) { .selectFrom('repo_seq') .selectAll() .where('seq', 'is not', null) - .where('sequencedAt', '>', time) + .where('sequencedAt', '>=', time) + .orderBy('sequencedAt', 'asc') .limit(1) - .orderBy('sequencedAt', 'desc') .executeTakeFirst() return got || null }