Skip to content

Commit 787a94d

Browse files
fix(server): doctor measures repair progress on the monotonic clock
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0421f7d commit 787a94d

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎apps/server/src/cli/doctor.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const formatBytes = (bytes: number) =>
1717
? `${(bytes / 1024 ** 2).toFixed(1)} MiB`
1818
: `${Math.ceil(bytes / 1024)} KiB`;
1919

20-
const formatElapsed = (millis: number) => {
21-
const seconds = Math.floor(millis / 1000);
20+
const formatElapsed = (nanos: bigint) => {
21+
const seconds = Number(nanos / 1_000_000_000n);
2222
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
2323
};
2424

@@ -115,9 +115,9 @@ export const runDoctor = Effect.fn("runDoctor")(function* (
115115
if (selected.includes("database")) {
116116
const service = yield* BootService.BootService;
117117
yield* Console.log("\nReclaiming database space. Each step is shown as it starts.");
118-
const startedAt = yield* Clock.currentTimeMillis;
118+
const startedAt = yield* Clock.monotonicTimeNanos;
119119
const reportStep = (step: DatabaseMaintenance.DatabaseCompactStep) =>
120-
Clock.currentTimeMillis.pipe(
120+
Clock.monotonicTimeNanos.pipe(
121121
Effect.flatMap((now) =>
122122
Console.log(` [${formatElapsed(now - startedAt)}] ${COMPACT_STEP_LABELS[step]}`),
123123
),
@@ -128,7 +128,7 @@ export const runDoctor = Effect.fn("runDoctor")(function* (
128128
.compact(databasePath, reportStep)
129129
.pipe(
130130
Effect.tap((result) =>
131-
Clock.currentTimeMillis.pipe(
131+
Clock.monotonicTimeNanos.pipe(
132132
Effect.flatMap((now) =>
133133
Console.log(
134134
`Done in ${formatElapsed(now - startedAt)}: ${formatBytes(result.beforeBytes)} -> ${formatBytes(result.afterBytes)}, ${result.deletedEventCount} superseded events removed.`,

0 commit comments

Comments
 (0)