Repository navigation
Closed
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- On the machine running T3 Code, put an expired rotated log such as server.log.1 in a subfolder of T3 Code’s logs folder.
- Add a symlink named 00-dangling.log.1 pointing to a missing file in the same subfolder.
- Open Settings → Maintenance.
- Enable deletion of old rotated logs.
- Click Delete now.
- Expand Last run.
Expected behavior
Cleanup skips the broken link and reports that it removed the expired log.
Actual behavior
Cleanup reports a failure for Rotated logs and leaves the expired log behind.
Impact
Minor bug or occasional failure. Users with a dangling symlink in their log tree can miss log retention on every manual or scheduled cleanup until the link is fixed or removed.
Version or commit
main at fcf50973f3. The cause is at apps/server/src/storageCleanup.ts:1813.
Environment
Linux x64 boat.dev default machine, a fresh checkout.
Logs or stack traces
Removed 1 rotated logsAutomated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/scripts/scenarios/cleanup-skips-dangling-log-symlink.e2e.ts b/scripts/scenarios/cleanup-skips-dangling-log-symlink.e2e.ts
new file mode 100644
index 0000000000..f86fdba249
--- /dev/null
+++ b/scripts/scenarios/cleanup-skips-dangling-log-symlink.e2e.ts
@@ -0,0 +1,73 @@
+import { expect } from "e2e";
+import * as Effect from "effect/Effect";
+import * as FileSystem from "effect/FileSystem";
+import * as Schema from "effect/Schema";
+
+import { T3_HOME } from "../e2e.config.ts";
+import { runPromise, test, WEB } from "./t3.ts";
+
+const decodeSettings = Schema.decodeSync(
+ Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown)),
+);
+
+test(
+ "Cleanup removes expired rotated logs even with a dangling symlink in the log directory",
+ WEB,
+ async ({ t3, app, browser, screen }) => {
+ await t3.project("rotated-log-cleanup");
+ const settingsPath = `${T3_HOME}/userdata/settings.json`;
+ const logFixture = `${T3_HOME}/userdata/logs/00-cleanup-fixture`;
+ const expiredLog = `${logFixture}/server.log.1`;
+ const original = await runPromise(
+ Effect.flatMap(FileSystem.FileSystem, (fs) => fs.readFileString(settingsPath)),
+ );
+
+ try {
+ await runPromise(
+ Effect.flatMap(FileSystem.FileSystem, (fs) =>
+ fs.writeFileString(
+ settingsPath,
+ JSON.stringify({ ...decodeSettings(original), storageCleanup: { logsAfterDays: 7 } }),
+ ),
+ ),
+ );
+ await t3.open("/settings/maintenance");
+ await screen.getByLabel("Delete old rotated logs in days").waitFor();
+
+ const deleteNow = screen.getByRole("button", "Delete now", { exact: true });
+ await deleteNow.tap();
+ await screen.getByRole("button", "Deleting…", { exact: true }).waitFor({ state: "hidden" });
+ await screen.getByRole("button", /^Last run/).tap();
+ const logsResult = browser
+ .locator('#storage-cleanup-last-run [data-slot="settings-row"]')
+ .filter({ has: screen.getByText("Rotated logs", { exact: true }) });
+ await logsResult.getByText("No expired files", { exact: true }).waitFor();
+
+ await runPromise(
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ yield* fs.makeDirectory(logFixture);
+ yield* fs.symlink(`${logFixture}/missing.log`, `${logFixture}/00-dangling.log.1`);
+ yield* fs.writeFileString(expiredLog, "Expired log");
+ yield* fs.utimes(expiredLog, 1, 1);
+ }),
+ );
+
+ await deleteNow.tap();
+ await logsResult.scrollIntoView();
+ try {
+ await expect(logsResult).toContainText("Removed 1 rotated logs");
+ } finally {
+ await app.screenshot("rotated-log-cleanup-result");
+ }
+ } finally {
+ await runPromise(
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ yield* fs.remove(logFixture, { recursive: true, force: true });
+ yield* fs.writeFileString(settingsPath, original);
+ }),
+ );
+ }
+ },
+);pnpm scenarios:prove scripts/scenarios/cleanup-skips-dangling-log-symlink.e2e.ts --base mainWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.


Activity