Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ export async function getExecutionSnapshotsSince(
completedWaitpoints: true,
checkpoint: true,
},
orderBy: { createdAt: "asc" },
orderBy: { createdAt: "desc" },
take: 50,
});

return snapshots.map(enhanceExecutionSnapshot);
return snapshots.reverse().map(enhanceExecutionSnapshot);
}
Comment on lines +219 to 224
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix pagination: current desc + reverse drops older snapshots.

With the new take: 50 cap, ordering desc and then reversing means we only ever return the latest 50 snapshots after sinceSnapshot. If more than 50 snapshots were created since then, the earlier ones (closest to sinceSnapshot) never get returned, so clients can’t page through the backlog without data loss. Please keep the query ascending so the first call yields the oldest 50 after the cursor.

-    orderBy: { createdAt: "desc" },
-    take: 50,
+    orderBy: { createdAt: "asc" },
+    take: 50,
   });
 
-  return snapshots.reverse().map(enhanceExecutionSnapshot);
+  return snapshots.map(enhanceExecutionSnapshot);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
orderBy: { createdAt: "desc" },
take: 50,
});
return snapshots.map(enhanceExecutionSnapshot);
return snapshots.reverse().map(enhanceExecutionSnapshot);
}
const snapshots = await prisma.executionSnapshot.findMany({
where: { /* ...existing filters...*/ },
orderBy: { createdAt: "asc" },
take: 50,
});
return snapshots.map(enhanceExecutionSnapshot);
}
🤖 Prompt for AI Agents
In internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts
around lines 219 to 224, the code queries snapshots with orderBy: { createdAt:
"desc" } and then reverses the result, which with take: 50 returns the newest 50
snapshots and drops older ones; change the query to orderBy: { createdAt: "asc"
} and remove the .reverse() so the database returns the oldest 50 snapshots
after sinceSnapshot (allowing correct pagination), then continue to map the
results with enhanceExecutionSnapshot.


export class ExecutionSnapshotSystem {
Expand Down
Loading