(client, level, message, extra)
| 425 | } |
| 426 | } |
| 427 | async function readStateFile(directory, sessionID) { |
| 428 | const target = statePath(directory, sessionID); |
| 429 | const attempts = 5; |
| 430 | for (let attempt = 0;attempt < attempts; attempt++) { |
| 431 | try { |
| 432 | const parsed = JSON.parse(await fs.readFile(target, "utf8")); |
| 433 | return { version: 4, jobs: Array.isArray(parsed.jobs) ? parsed.jobs : [] }; |
| 434 | } catch (error) { |
| 435 | if (error?.code === "ENOENT") |
| 436 | return { version: 4, jobs: [] }; |
| 437 | const transient = error instanceof SyntaxError || isRetriableStateWriteError(error); |
| 438 | if (!transient || attempt === attempts - 1) |
no test coverage detected