Runs the job, remembers its failure and releases the resources it holds. Never rejects.
(key: string, bytes: number, job: () => Promise<void>)
| 90 | |
| 91 | /** Runs the job, remembers its failure and releases the resources it holds. Never rejects. */ |
| 92 | private async execute(key: string, bytes: number, job: () => Promise<void>): Promise<void> { |
| 93 | try { |
| 94 | await job(); |
| 95 | } catch (error) { |
| 96 | if (!this.failure) { |
| 97 | this.failure = {error}; |
| 98 | this.rejectFailed(error); |
| 99 | } |
| 100 | } finally { |
| 101 | this.runningKeys.delete(key); |
| 102 | this.runningBytes -= bytes; |
| 103 | } |
| 104 | } |
| 105 | } |