Skip to content

Commit

Permalink
prevent exponentially multiplying setIntervals on pending build cards (
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhollen authored May 26, 2023
1 parent 438de8f commit 0b949a4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion enterprise/app/history/history_invocation_card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ export default class HistoryInvocationCardComponent extends React.Component<Prop

updateTimeIfInProgress() {
if (!this.isInProgress()) {
if (this.interval) {
window.clearInterval(this.interval);
}
return;
}
this.setState({ time: Date.now() });
this.interval = window.setInterval(() => this.updateTimeIfInProgress(), durationRefreshIntervalMillis);
if (!this.interval) {
this.interval = window.setInterval(() => {
this.updateTimeIfInProgress();
}, durationRefreshIntervalMillis);
}
}

componentWillUnmount() {
Expand Down

0 comments on commit 0b949a4

Please sign in to comment.