Skip to content

Commit 117f635

Browse files
committed
server: avoid skipping builds if we can't fetch them
Due to GitHub API inconsistencies, it might happen that fetching the build from the API the first time fails. This will return an error, causing a return before the ID could be removed from the "seen" list. This fixes the problem by moving adding a crate to the "seen" list after such requests.
1 parent b07454c commit 117f635

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/bin/server/worker.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ impl Worker {
126126
info!("build {}: ignoring recently seen id", build_id);
127127
return Ok(());
128128
}
129-
self.seen.push_front(build_id);
130-
if self.seen.len() > KEEP_IDS {
131-
self.seen.pop_back();
132-
}
133-
134129
let query_from = if self.query_builds_from_primary_repo {
135130
&self.repo
136131
} else {
@@ -145,18 +140,20 @@ impl Worker {
145140

146141
debug!("build {}: current outcome: {:?}", build_id, outcome);
147142
debug!("build {}: PR number: {:?}", build_id, build.pr_number());
148-
debug!("build {}: branch name: {:?}", build_id, build.pr_number(),);
143+
debug!("build {}: branch name: {:?}", build_id, build.pr_number());
149144

150145
if !outcome.is_finished() {
151146
info!("build {}: ignoring in-progress build", build_id);
152-
if let Some(idx) = self.seen.iter().position(|id| *id == build_id) {
153-
// Remove ignored builds, as we haven't reported anything for them and the
154-
// in-progress status might be misleading (e.g., leading edge of a group of
155-
// notifications).
156-
self.seen.remove(idx);
157-
}
158147
return Ok(());
159148
}
149+
150+
// Avoid processing the same build multiple times.
151+
info!("build {}: marked as seen", build_id);
152+
self.seen.push_front(build_id);
153+
if self.seen.len() > KEEP_IDS {
154+
self.seen.pop_back();
155+
}
156+
160157
if !outcome.is_passed() {
161158
info!("build {}: preparing report", build_id);
162159
self.report_failed(build.as_ref())?;

0 commit comments

Comments
 (0)