Skip to content

Commit beaf9b7

Browse files
committed
perf(webapp): resolve the internal-api-origin global default from the cached flags registry
Review follow-ups: the global default now comes from the in-memory globalFlagsRegistry snapshot (cold read fails safe to the public origin) instead of a per-attempt featureFlag query, and the deliberate non-switching of TRIGGER_STREAM_URL is documented.
1 parent ecc1052 commit beaf9b7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getSecretStore } from "~/services/secrets/secretStore.server";
88
import { deduplicateVariableArray } from "../deduplicateVariableArray.server";
99
import { removeBlacklistedVariables } from "../environmentVariableRules.server";
1010
import { FEATURE_FLAG, resolveInternalApiOriginEnabled } from "../featureFlags";
11-
import { flag } from "../featureFlags.server";
11+
import { globalFlagsRegistry } from "../globalFlagsRegistry.server";
1212
import { generateFriendlyId } from "../friendlyIdentifiers";
1313
import {
1414
type CreateEnvironmentVariables,
@@ -1169,10 +1169,8 @@ async function resolveProdApiOrigin(
11691169

11701170
const enabled = resolveInternalApiOriginEnabled({
11711171
orgFeatureFlags: organization?.featureFlags,
1172-
globalDefault: await flag({
1173-
key: FEATURE_FLAG.internalApiOriginEnabled,
1174-
defaultValue: false,
1175-
}),
1172+
// Cached global snapshot; a cold read fails safe to the public origin.
1173+
globalDefault: globalFlagsRegistry.current()?.[FEATURE_FLAG.internalApiOriginEnabled] ?? false,
11761174
});
11771175

11781176
return enabled ? env.INTERNAL_API_ORIGIN : publicOrigin;
@@ -1194,6 +1192,8 @@ async function resolveBuiltInProdVariables(
11941192
value: apiOrigin,
11951193
},
11961194
{
1195+
// Deliberately not switched by internalApiOriginEnabled: streams are
1196+
// long-lived connections served on their own path.
11971197
key: "TRIGGER_STREAM_URL",
11981198
value: env.STREAM_ORIGIN ?? env.API_ORIGIN ?? env.APP_ORIGIN,
11991199
},

0 commit comments

Comments
 (0)