Skip to content

Commit

Permalink
Merge pull request #484 from PagerDuty/unique_incidents
Browse files Browse the repository at this point in the history
  • Loading branch information
gsreynolds authored Aug 8, 2024
2 parents 83b65dc + b632bd2 commit b45b9ce
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/redux/incidents/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function* getIncidentsImpl() {
until,
include: ['first_trigger_log_entries', 'external_references'],
limit: INCIDENTS_PAGINATION_LIMIT,
sort_by: 'created_at:desc',
sort_by: 'incident_number:desc',
};

if (incidentStatus) baseParams.statuses = incidentStatus;
Expand All @@ -129,6 +129,17 @@ export function* getIncidentsImpl() {
connectionStatusMessage: 'Unable to fetch incidents',
});
}
// The incident list API may return duplicate incidents under some circumstances, so as a precaution we'll dedupe the list by incident.id
// Also log a RUM error if we find any duplicates
const duplicateIncidents = incidents.filter((incident, index, self) => self.findIndex((t) => t.id === incident.id) !== index);
const numDuplicateIncidents = duplicateIncidents.length;
if (numDuplicateIncidents > 0) {
// eslint-disable-next-line no-console
console.error('Duplicate incidents found', numDuplicateIncidents);
RealUserMonitoring.trackError(new Error('Duplicate incidents found'), numDuplicateIncidents);
incidents = incidents.filter((incident, index, self) => self.findIndex((t) => t.id === incident.id) === index);
}

return incidents;
}

Expand Down

0 comments on commit b45b9ce

Please sign in to comment.