Skip to content

Commit 9f2e4ac

Browse files
t3dotggclaude
andcommitted
fix(server): read the database only for a crossing that can proceed; a close failure never escapes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 88b4393 commit 9f2e4ac

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎apps/server/src/cloud/selfUpdate.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ export const make = Effect.fn("cloud.server_self_update.make")(function* () {
153153
const update: ServerSelfUpdate["Service"]["update"] = Effect.fn(
154154
"cloud.server_self_update.update",
155155
)(function* (input, reportProgress = () => Effect.void, onHandoffAccepted = () => Effect.void) {
156-
const unsafeDowngrade = crossesTrackUnsafely(input);
157156
if (capability === "desktop-managed") {
158-
if (input.channel !== undefined && unsafeDowngrade !== null) {
159-
return yield* failWith(unsafeDowngrade);
160-
}
157+
const unsafeCrossing = input.channel === undefined ? null : crossesTrackUnsafely(input);
158+
if (unsafeCrossing !== null) return yield* failWith(unsafeCrossing);
161159
if (desktopAppUpdate.available) {
162160
return yield* desktopAppUpdate.run(
163161
reportProgress,
@@ -176,7 +174,8 @@ export const make = Effect.fn("cloud.server_self_update.make")(function* () {
176174
);
177175
}
178176

179-
if (unsafeDowngrade !== null) return yield* failWith(unsafeDowngrade);
177+
const unsafeCrossing = crossesTrackUnsafely(input);
178+
if (unsafeCrossing !== null) return yield* failWith(unsafeCrossing);
180179
const targetVersion = input.targetVersion.trim();
181180
if (!isExactServiceVersion(targetVersion)) {
182181
return yield* failWith(`'${targetVersion}' is not an exact t3 version.`);

‎apps/server/src/persistence/databaseMigrationHead.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export function recordedMigrations(
3131
} catch {
3232
return null;
3333
} finally {
34-
db.close();
34+
try {
35+
db.close();
36+
} catch {
37+
// A read-only handle has nothing to flush; the result above already stands.
38+
}
3539
}
3640
}
3741

0 commit comments

Comments
 (0)