(filePath: string)
| 108 | const MAX_CLOCK_FILE_BYTES = 64; |
| 109 | |
| 110 | function readFileWall(filePath: string): number { |
| 111 | let bytesRead = 0; |
| 112 | const buf = Buffer.alloc(MAX_CLOCK_FILE_BYTES); |
| 113 | let fd: number; |
| 114 | try { |
| 115 | fd = openSync(filePath, 'r'); |
| 116 | } catch { |
| 117 | return Date.now(); |
| 118 | } |
| 119 | try { |
| 120 | bytesRead = readSync(fd, buf, 0, MAX_CLOCK_FILE_BYTES, 0); |
| 121 | } catch { |
| 122 | return Date.now(); |
| 123 | } finally { |
| 124 | try { |
| 125 | closeSync(fd); |
| 126 | } catch { |
| 127 | /* swallow close errors */ |
| 128 | } |
| 129 | } |
| 130 | const raw = buf.subarray(0, bytesRead).toString('utf8'); |
| 131 | const firstLine = raw.split('\n', 1)[0]?.trim() ?? ''; |
| 132 | if (firstLine === '') return Date.now(); |
| 133 | const parsed = Number(firstLine); |
| 134 | if (!Number.isFinite(parsed)) return Date.now(); |
| 135 | return parsed; |
| 136 | } |
| 137 | |
| 138 | function debugInvalidSpec(spec: string, reason: string): void { |
| 139 | // We do not pull in a logger here — `clock.ts` is the lowest layer of |
no test coverage detected