Skip to content

Commit

Permalink
fix: delay evaluation to finish preprocessing
Browse files Browse the repository at this point in the history
A temporary hacky fix for #64

Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
  • Loading branch information
bajtos committed May 20, 2024
1 parent 4ffeffd commit dadad77
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const startEvaluate = async ({
}
}

const onRoundStart = (_roundIndex) => {
const onRoundStart = async (_roundIndex) => {
const roundIndex = BigInt(_roundIndex)
if (roundsSeen.includes(roundIndex)) return
roundsSeen.push(roundIndex)
Expand All @@ -85,6 +85,14 @@ export const startEvaluate = async ({
return
}

// TODO: Fix this properly and implement a signalling mechanism allowing the "preprocess" step
// to notify the "evaluate" when the preprocessing is done, so that we don't have to use a timer
// here. See also https://github.com/filecoin-station/spark-evaluate/issues/64
const delay = PREPROCESS_DELAY + 60_000
console.log(`Sleeping for ${delay}ms before evaluating the round to let the preprocess step finish for the last batch of measurements`)
await timers.setTimeout(delay)
console.log(`Now evaluating the round ${roundIndex}`)

rounds.previous = rounds.current
rounds.current = new RoundData(roundIndex)

Expand Down Expand Up @@ -121,7 +129,10 @@ export const startEvaluate = async ({
Sentry.captureException(err)
})
} else if (event.name === 'RoundStart') {
onRoundStart(...event.args)
onRoundStart(...event.args).catch(err => {
console.error(err)
Sentry.captureException(err)
})
}
}
}

0 comments on commit dadad77

Please sign in to comment.