Some people are going to think this is too trivial to look for modules or almost put it in a leftPad category perhaps, but there are so many things in npm I have a feeling these two requirements are covered and so am interested to see what other people have done.
I inherited this codebase that has this sort of long updating function with a number of steps. It has sort of a custom locking flag that is half-set-up to expire but doesn't actually have the expiration code. Anyway, the main thing is to prevent the update from happening while something else is happening. Except sometimes we know we definitely need to update as soon as possible, but not right in the middle of a current update. This stuff is not actually quite working.
So I am looking for one or two modules to do two things:
a lock with an expiration that two different long-running functions (that call other functions with callbacks) can use to make sure they don't step on each other
a simple module/function that says 'do this function now, or run it again after it finishes its current run'.
Or possibly something that handles both of those might actually make sense in this case, even though from my description it may not be obvious what they have to do with each other.
The expiration is if there is some case that I don't anticipate that causes the lock not to be removed, we don't want to be stuck forever.