Skip to main content

Practice ยท 3 of 3

Cleanup With finally

Write async function withLock(lock, job) where lock has acquire() and release() (both promise-returning). Acquire, run job(), and ALWAYS release โ€” whether the job succeeded or threw. RETURN the job's result; if the job threw, rethrow after releasing.

Difficulty: intermediate

Back to lesson: Practice: Promises โ€” Practice