fix(clients): disable incompatible environments during discovery #11990
Mergedjuliusmarmingemerged 3 commits into
main fromrefs/pull/11990/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:L
- packages/client-runtime/src/connection/layer.ts line 46OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -26,3 +29,18 @@2629 Effect.gen(function* () {2730 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;2831 const platformSource = yield* PlatformConnectionSource.PlatformConnectionSource;32+ const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery;33+ yield* Stream.merge(34+ SubscriptionRef.changes(discovery.state).pipe(Stream.map(() => true)),35+ SubscriptionRef.changes(registry.entries).pipe(Stream.map(() => false)),36+ ).pipe(37+ Stream.runForEach((discoveryChanged) =>38+ Effect.gen(function* () {39+ for (const entry of (yield* SubscriptionRef.get(40+ discovery.state,41+ )).environments.values()) {42+ const descriptor = Option.getOrNull(entry.status)?.descriptor;43+ if (descriptor !== undefined) {44+ const error = orchestrationProtocolCompatibilityError(descriptor);45+ // A cached relay response must not clear a newer socket preflight rejection.46+ if (error !== null || discoveryChanged) {
juliusmarminge changed the title
- packages/client-runtime/src/connection/layer.ts lines 37 to 40OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -13,0 +20,21 @@20+ const registry = yield* EnvironmentRegistry.EnvironmentRegistry;21+ const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery;22+ const seenDescriptors = new Map<string, ExecutionEnvironmentDescriptor>();23+ yield* Stream.merge(24+ SubscriptionRef.changes(discovery.state),25+ SubscriptionRef.changes(registry.entries),26+ ).pipe(27+ Stream.runForEach(() =>28+ Effect.gen(function* () {29+ const current = yield* SubscriptionRef.get(discovery.state);30+ for (const environmentId of seenDescriptors.keys()) {31+ if (!current.environments.has(environmentId)) seenDescriptors.delete(environmentId);32+ }33+ for (const entry of current.environments.values()) {34+ const descriptor = Option.getOrNull(entry.status)?.descriptor;35+ if (descriptor === undefined) continue;36+ const environmentId = entry.environment.environmentId;37+ const fresh = seenDescriptors.get(environmentId) !== descriptor;38+ const error = orchestrationProtocolCompatibilityError(descriptor);39+ // Only a new descriptor for this environment can clear a socket rejection.40+ if (error !== null || fresh) yield* registry.setCompatibility(environmentId, error);
juliusmarminge merged this935c55b
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed