Skip to content

Commit d5344ec

Browse files
committed
fix: address three application issues
- Increase desktop bootstrap token TTL from 5 to 10 minutes to prevent expiration before the renderer can exchange it during slow startups - Remove dead buildReconnectTitle function (unused _status param after refactor) and inline the constant string at the call site - Scope cached session token in tests to a build generation counter so stale tokens from prior server instances cannot leak across tests
1 parent 5a21931 commit d5344ec

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

apps/server/src/auth/Layers/BootstrapCredentialService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ConsumeResult =
2222
readonly grant: BootstrapGrant;
2323
};
2424

25-
const DEFAULT_ONE_TIME_TOKEN_TTL_MINUTES = Duration.minutes(5);
25+
const DEFAULT_ONE_TIME_TOKEN_TTL_MINUTES = Duration.minutes(10);
2626

2727
export const makeBootstrapCredentialService = Effect.gen(function* () {
2828
const config = yield* ServerConfig;

apps/server/src/server.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ const testEnvironmentDescriptor = {
108108
repositoryIdentity: true,
109109
},
110110
};
111-
let cachedDefaultSessionToken: string | null = null;
111+
let serverBuildGeneration = 0;
112+
let cachedDefaultSessionToken: { token: string; generation: number } | null = null;
112113

113114
const makeDefaultOrchestrationReadModel = () => {
114115
const now = new Date().toISOString();
@@ -293,7 +294,7 @@ const buildAppUnderTest = (options?: {
293294
};
294295
}) =>
295296
Effect.gen(function* () {
296-
cachedDefaultSessionToken = null;
297+
serverBuildGeneration += 1;
297298
const fileSystem = yield* FileSystem.FileSystem;
298299
const tempBaseDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-router-test-" });
299300
const baseDir = options?.config?.baseDir ?? tempBaseDir;
@@ -521,8 +522,13 @@ const bootstrapBrowserSession = (credential = defaultDesktopBootstrapToken) =>
521522

522523
const getAuthenticatedSessionToken = (credential = defaultDesktopBootstrapToken) =>
523524
Effect.gen(function* () {
524-
if (credential === defaultDesktopBootstrapToken && cachedDefaultSessionToken) {
525-
return cachedDefaultSessionToken;
525+
const currentGeneration = serverBuildGeneration;
526+
if (
527+
credential === defaultDesktopBootstrapToken &&
528+
cachedDefaultSessionToken &&
529+
cachedDefaultSessionToken.generation === currentGeneration
530+
) {
531+
return cachedDefaultSessionToken.token;
526532
}
527533

528534
const { response, body } = yield* bootstrapBrowserSession(credential);
@@ -533,7 +539,7 @@ const getAuthenticatedSessionToken = (credential = defaultDesktopBootstrapToken)
533539
}
534540

535541
if (credential === defaultDesktopBootstrapToken) {
536-
cachedDefaultSessionToken = body.sessionToken;
542+
cachedDefaultSessionToken = { token: body.sessionToken, generation: currentGeneration };
537543
}
538544

539545
return body.sessionToken;

apps/web/src/components/WebSocketConnectionSurface.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ function describeExhaustedToast(): string {
5454
return "Retries exhausted trying to reconnect";
5555
}
5656

57-
function buildReconnectTitle(_status: WsConnectionStatus): string {
58-
return "Disconnected from T3 Server";
59-
}
60-
6157
function describeRecoveredToast(
6258
previousDisconnectedAt: string | null,
6359
connectedAt: string | null,
@@ -270,7 +266,7 @@ export function WebSocketConnectionCoordinator() {
270266
? `Reconnecting... ${formatReconnectAttemptLabel(status)}`
271267
: `Reconnecting in ${formatRetryCountdown(status.nextRetryAt, nowMs)}... ${formatReconnectAttemptLabel(status)}`,
272268
timeout: 0,
273-
title: buildReconnectTitle(status),
269+
title: "Disconnected from T3 Server",
274270
type: "loading" as const,
275271
data: {
276272
hideCopyButton: true,

0 commit comments

Comments
 (0)