()
| 383 | } |
| 384 | |
| 385 | private async writeCacheToDisk(): Promise<void> { |
| 386 | try { |
| 387 | const experiments: ExperimentsCacheFile["experiments"] = {}; |
| 388 | for (const [experimentId, cached] of this.cachedVariants) { |
| 389 | experiments[experimentId] = { |
| 390 | value: cached.value, |
| 391 | fetchedAtMs: cached.fetchedAtMs, |
| 392 | }; |
| 393 | } |
| 394 | |
| 395 | const overrides: NonNullable<ExperimentsCacheFile["overrides"]> = {}; |
| 396 | for (const [experimentId, enabled] of this.overrides) { |
| 397 | overrides[experimentId] = enabled; |
| 398 | } |
| 399 | |
| 400 | const payload: ExperimentsCacheFile = { |
| 401 | version: CACHE_FILE_VERSION, |
| 402 | experiments, |
| 403 | overrides, |
| 404 | }; |
| 405 | |
| 406 | await fs.mkdir(this.muxHome, { recursive: true }); |
| 407 | await writeFileAtomic(this.cacheFilePath, JSON.stringify(payload, null, 2), "utf-8"); |
| 408 | } catch { |
| 409 | // Ignore cache persistence failures |
| 410 | } |
| 411 | } |
| 412 | } |
no outgoing calls
no test coverage detected