[UI] Fix Status Check Leak (#853)
This commit is contained in:
parent
99c27f8fac
commit
b4a1c293dc
|
@ -105,15 +105,21 @@ export function usePRChecksDecision({
|
||||||
}, [data]) // eslint-disable-line react-hooks/exhaustive-deps
|
}, [data]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
let tornDown = false
|
||||||
const pollingFn = () => {
|
const pollingFn = () => {
|
||||||
if (repoMetadata?.path && pullRequestMetadata?.source_sha && !complete) {
|
if (repoMetadata?.path && pullRequestMetadata?.source_sha && !complete && !tornDown) {
|
||||||
refetch().then(() => {
|
// TODO: fix racing condition where an ongoing refetch of the old sha overwrites the new one.
|
||||||
|
// TEMPORARY SOLUTION: set debounce to 1 second to reduce likelyhood
|
||||||
|
refetch({ debounce: 1 }).then(() => {
|
||||||
interval = window.setTimeout(pollingFn, POLLING_INTERVAL)
|
interval = window.setTimeout(pollingFn, POLLING_INTERVAL)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let interval = window.setTimeout(pollingFn, POLLING_INTERVAL)
|
let interval = window.setTimeout(pollingFn, POLLING_INTERVAL)
|
||||||
return () => window.clearTimeout(interval)
|
return () => {
|
||||||
|
tornDown = true
|
||||||
|
window.clearTimeout(interval)
|
||||||
|
}
|
||||||
}, [repoMetadata?.path, pullRequestMetadata?.source_sha, complete]) // eslint-disable-line react-hooks/exhaustive-deps
|
}, [repoMetadata?.path, pullRequestMetadata?.source_sha, complete]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue