From 2dba27e41cb7c6c181fb97261ef30710f668e461 Mon Sep 17 00:00:00 2001 From: James Houghton Date: Thu, 19 Oct 2023 13:26:49 -0400 Subject: [PATCH] fix recursive return (#660) --- cypress/e2e/06_Many_Games.js | 2 +- server/src/github.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/06_Many_Games.js b/cypress/e2e/06_Many_Games.js index 47d4c6ef..bcd1b95c 100644 --- a/cypress/e2e/06_Many_Games.js +++ b/cypress/e2e/06_Many_Games.js @@ -122,7 +122,7 @@ describe("Many Games", { retries: { runMode: 2, openMode: 0 } }, () => { const valueCounts = (a) => new Map([...new Set(a)].map((x) => [x, a.filter((y) => y === x).length])); - // check that player 1's data is exported even though player 2 is not finished + // check that each room has two players assigned to it, as expected cy.get("@dataObjects").then((dataObjects) => { const recordingsFolders = dataObjects.map((obj) => obj.recordingsFolder); const counts = valueCounts(recordingsFolders); diff --git a/server/src/github.js b/server/src/github.js index adf7fb6a..2c4ddf5e 100644 --- a/server/src/github.js +++ b/server/src/github.js @@ -71,7 +71,7 @@ export async function commitFile({ directory, filepath, throwErrors, // if true, raises errors on commit failure - retries = 3, + retries = 0, }) { const filename = path.basename(filepath); @@ -109,7 +109,7 @@ export async function commitFile({ return true; } catch (e) { if (e.status === 409) { - log( + warn( `Conflict committing file ${filename} to repository ${owner}/${repo}/${branch}/${directory}, likely out-of-date sha` ); } else { @@ -122,8 +122,8 @@ export async function commitFile({ if (throwErrors) throw e; if (retries > 0) { - log(`Retrying commit of ${filename} (${retries} tries left))`); - await commitFile({ + info(`Retrying commit of ${filename} (${retries} tries left))`); + const success = await commitFile({ owner, repo, branch, @@ -132,13 +132,13 @@ export async function commitFile({ throwErrors, // if true, raises errors on commit failure retries: retries - 1, }); + return success; } error( `Failed to commit ${filename} to ${owner}/${repo}/${branch}/${directory}. No retries left.`, e ); - return false; } } @@ -173,6 +173,7 @@ export async function pushPreregToGithub({ batch, delaySeconds = 60 }) { branch, directory, filepath: preregistrationDataFilename, + retries: 3, }); }); // Todo: Add treatment description file push to private repo @@ -218,6 +219,7 @@ export async function pushDataToGithub({ directory, filepath: scienceDataFilename, throwErrors, + retries: 3, }); }) );