()
| 142 | } |
| 143 | |
| 144 | async saveLastError() { |
| 145 | const now = new Date(); |
| 146 | const failedAt = |
| 147 | "" + |
| 148 | now.getFullYear() + |
| 149 | "/" + |
| 150 | ("0" + (now.getMonth() + 1)).slice(-2) + |
| 151 | "/" + |
| 152 | ("0" + now.getDate()).slice(-2) + |
| 153 | " " + |
| 154 | ("0" + now.getHours()).slice(-2) + |
| 155 | ":" + |
| 156 | ("0" + now.getMinutes()).slice(-2) + |
| 157 | ":" + |
| 158 | ("0" + now.getSeconds()).slice(-2); |
| 159 | const backtrace = this.worker.error.stack |
| 160 | ? this.worker.error.stack.split(os.EOL) || [] |
| 161 | : []; |
| 162 | |
| 163 | const data = { |
| 164 | failed_at: failedAt, |
| 165 | payload: this.args, |
| 166 | exception: String(this.worker.error), |
| 167 | error: String(this.worker.error), |
| 168 | backtrace: backtrace, |
| 169 | worker: this.func, |
| 170 | queue: this.queue, |
| 171 | }; |
| 172 | |
| 173 | await this.redis().setex( |
| 174 | this.failureKey(), |
| 175 | this.maxDelay(), |
| 176 | JSON.stringify(data), |
| 177 | ); |
| 178 | } |
| 179 | |
| 180 | async cleanup() { |
| 181 | await this.redis().del(this.retryKey()); |
no test coverage detected