Skip to content

Commit

Permalink
clear refresh interval timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Mar 27, 2024
1 parent 6118568 commit 4bfe17b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/jsreport-fs-store/lib/fileSystem.js
Expand Up @@ -130,12 +130,15 @@ module.exports = ({ dataDirectory, lock, externalModificationsSync }) => ({
const refreshInterval = setInterval(() => touch(path.join(dataDirectory, 'fs.lock')), this.lockOptions.stale / 2)
refreshInterval.unref()
const undelegateWait = this.lockOptions.wait * (this.lockOptions.retries || 1) + ((this.lockOptions.retries || 1) * (this.lockOptions.retryWait || 0))
setTimeout(() => clearInterval(refreshInterval), undelegateWait).unref()

return { refreshInterval }
const clearRefreshIntervalTimeout = setTimeout(() => clearInterval(refreshInterval), undelegateWait)
clearRefreshIntervalTimeout.unref()

return { refreshInterval, clearRefreshIntervalTimeout }
},
async releaseLock (l) {
clearInterval(l.refreshInterval)
clearTimeout(l.clearRefreshIntervalTimeout)
await callUnlock(path.join(dataDirectory, 'fs.lock'))
}
})
Expand Down

0 comments on commit 4bfe17b

Please sign in to comment.