()
| 129 | } |
| 130 | |
| 131 | private async load(): Promise<MemoryMetaFile> { |
| 132 | if (this.cache !== null) return this.cache; |
| 133 | let parsed: unknown = null; |
| 134 | try { |
| 135 | parsed = JSON.parse(await fsPromises.readFile(this.metaPath, "utf-8")); |
| 136 | } catch (error) { |
| 137 | // Missing file is the normal first-run case; anything else is healed to empty. |
| 138 | if ((error as NodeJS.ErrnoException).code !== "ENOENT") { |
| 139 | log.debug("[MemoryMetaService] healing unreadable sidecar", { error }); |
| 140 | } |
| 141 | } |
| 142 | this.cache = sanitizeMetaFile(parsed); |
| 143 | return this.cache; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Read-modify-write cycle under the sidecar mutex. Persists before updating |
no test coverage detected