mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 14:19:01 +02:00
cb9d207ba0
[SmokeTests] rewrite GitOrigin-RevId: eda39db6b339d997f5669cb9bfca2aefe7d96699
19 lines
394 B
JavaScript
19 lines
394 B
JavaScript
async function processWithTimeout({ work, timeout, message }) {
|
|
let workDeadLine
|
|
function checkInResults() {
|
|
clearTimeout(workDeadLine)
|
|
}
|
|
await Promise.race([
|
|
new Promise((resolve, reject) => {
|
|
workDeadLine = setTimeout(() => {
|
|
reject(new Error(message))
|
|
}, timeout)
|
|
}),
|
|
work.finally(checkInResults)
|
|
])
|
|
}
|
|
|
|
module.exports = {
|
|
processWithTimeout
|
|
}
|