I want to stop a function execution from caller after 10s, e.g:
let done = false
setTimeout(() => {
if (!done) throw new Error('Function timeout')
}, 10000)
await someClientCodeHere()
done = true
This code works if something is waiting (i.e: on task queue/priority queue) but doesn't work if I put a for loop inside someClientCodeHere
.
My question is: Is there anyway to stop a function that is on callStack?