Make sorting/limit more resilient in repository

This commit is contained in:
Jon Staab
2025-10-28 13:23:25 -07:00
parent 8b8e3a6a51
commit 3132b8c59a
15 changed files with 16 additions and 24 deletions
+1 -1
View File
@@ -207,7 +207,7 @@ export const pull = async ({context, ...options}: PullOptions) => {
await Promise.all(
Array.from(idsByRelay.entries()).map(([relay, allIds]) => {
return Promise.all(
chunk(500, allIds).map(
chunk(100, allIds).map(
ids =>
new Promise<void>(resolve =>
requestOne({
+1 -5
View File
@@ -154,15 +154,11 @@ export class Repository extends Emitter {
) => {
const result: TrustedEvent[][] = []
for (const originalFilter of filters) {
if (originalFilter.limit !== undefined && !shouldSort) {
throw new Error("Unable to skip sorting if limit is defined")
}
// Attempt to fulfill the query using one of our indexes. Fall back to all events.
const applied = this._applyAnyFilter(originalFilter)
const filter = applied?.filter || originalFilter
const events = applied ? this._getEvents(applied!.ids) : this.dump()
const sorted = this._sortEvents(shouldSort && Boolean(filter.limit), events)
const sorted = this._sortEvents(shouldSort || Boolean(filter.limit), events)
const chunk: TrustedEvent[] = []
for (const event of sorted) {