Hacker News new | ask | show | jobs
by SamReidHughes 2398 days ago
Well, you have to cancel the task, not ignore it. So you need some standard cancellation hook. And that generally has to be something explicitly handled by the task in question; it cannot automatically percolate all the way down to the deepest sub-task.

If your promise lib has cancellation built in, then adding a timeout to one is easy.

1 comments

oh, shit. that means if i just send a timeout promise and a worker promise to Promise.race([...]), and the timeout finishes but the worker never does... then I have some unfulfilled promise hanging out somewhere indefinitely? I guess so... if I do Promise.race([p1, p2]) and p1 fulfills and p2 doesn't, p2 is still alive...indefinitely. Am I right or wrong...?