Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion packages/core/src/store/retrySubstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ export class RetrySubstore {
return;
}

results.push(testResult);
const existingIndex = results.findIndex((attempt) => attempt.id === testResult.id);

if (existingIndex !== -1) {
results.splice(existingIndex, 1, testResult);
} else {
results.push(testResult);
}

results.sort((first, second) => this.#compareResults(first, second));

results.forEach((attempt, index) => {
Expand Down
14 changes: 14 additions & 0 deletions packages/core/test/store/retrySubstore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ describe("RetrySubstore", () => {
expect(other.isRetry).toBe(true);
});

it("does not return a duplicate retry when the same id is upserted again", () => {
const rs = new RetrySubstore();
const first = { ...makeTr("same"), start: 100 };
const other = { ...makeTr("other"), start: 200 };

upsertInOrder(rs, first, other);

const updated = { ...first, start: 500 };

rs.upsert(updated);

expect(rs.retriesByTr(updated).map(({ id }) => id)).toEqual(["other"]);
});

it("does not index attempts without retryHash", () => {
const rs = new RetrySubstore();
const tr = { ...makeTr("solo"), retryHash: undefined };
Expand Down