fix(connect): refresh HTTP credentials without reconnecting #9594
Mergedjuliusmarmingemerged 8 commits into
main fromrefs/pull/9594/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- packages/client-runtime/src/state/environmentHttpAuth.ts line 125OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -73,0 +105,21 @@105+ for (;;) {106+ let httpBaseUrl = input.prepared.httpBaseUrl;107+ let authorization = input.prepared.httpAuthorization;108+ if (authorization?._tag === "Dpop") {109+ const remote = input.remoteAuthorization;110+ if (remote === undefined || Option.isNone(remote)) {111+ return yield* new RemoteEnvironmentAuthFetchError({112+ message: "No relay authorization service is available for the environment request.",113+ cause: input.prepared.target._tag,114+ });115+ }116+ const current = yield* remote.value117+ .authorizeDpopHttp({118+ expectedEnvironmentId: input.prepared.environmentId,119+ ...(rejectedAccessToken === undefined ? {} : { rejectedAccessToken }),120+ })121+ .pipe(122+ Effect.mapError(123+ (cause) =>124+ new RemoteEnvironmentAuthFetchError({125+ message: `Could not authorize the environment request: ${cause.detail}`,
- packages/client-runtime/src/state/environmentHttpAuth.ts line 184OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -73,0 +164,21 @@164+ ) {165+ if (rejectedAccessToken === undefined) {166+ rejectedAccessToken = authorization.accessToken;167+ continue;168+ }169+ return yield* new RemoteEnvironmentAuthFetchError({170+ message: "The environment rejected the renewed session authorization.",171+ cause: result.success,172+ });173+ }174+ return result.success;175+ }176+ },177+ (effect, input) =>178+ effect.pipe(179+ Effect.timeoutOrElse({180+ duration: input.timeoutMs,181+ orElse: () =>182+ Effect.fail(183+ new RemoteEnvironmentAuthTimeoutError(184+ input.url(input.prepared.httpBaseUrl),
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- packages/client-runtime/src/authorization/service.ts lines 370 to 370Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -316,0 +347,21 @@347+ reason: "configuration",348+ detail: "Could not load the environment authorization key.",349+ }),350+ ),351+ Effect.withSpan("environment.authorization.dpopKey.resolve"),352+ );353+ const selected = yield* tokenLock.withPermits(1)(354+ Effect.gen(function* () {355+ yield* assertSession(identity);356+ const now = yield* Clock.currentTimeMillis;357+ const cached = yield* tokenStore358+ .get(input.expectedEnvironmentId)359+ .pipe(Effect.withSpan("environment.authorization.accessToken.cache"));360+ const owner = tokenOwners.get(input.expectedEnvironmentId);361+ if (362+ Option.isSome(cached) &&363+ cached.value.environmentId === input.expectedEnvironmentId &&364+ cached.value.dpopThumbprint === thumbprint &&365+ cached.value.expiresAtEpochMs > now + DPOP_ACCESS_TOKEN_REFRESH_SKEW_MS &&366+ cached.value.accessToken !== input.rejectedAccessToken &&367+ (owner?.accessToken !== cached.value.accessToken || owner.identity === identity)
juliusmarminge merged this363cde4
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
4ade365· PR result:010646e· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.