Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client-runtime): queries stay pending while a connection hands off #18155

Mergedtris203(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/18155/headmerged by juliusmarminge View on GitHub

Showing 4 changed files with 116 additions and 4 deletions (loading 1).

x
0 of 4 viewed, 4 left
22 additions and 0 deletionspackages/client-runtime/src/connection/registry.test.tsModified
View file
@@ -637,6 +637,28 @@
}),
​
+ it.effect("does not expose a persisted environment as disconnected while it starts", () =>
+ Effect.gen(function* () {
+ const connectionStarted = yield* Deferred.make<void>();
+ const finishConnection = yield* Deferred.make<void>();
+ const harness = yield* makeHarness([TARGET], [], [], {
+ beforeSessionConnect: () =>
+ Deferred.succeed(connectionStarted, undefined).pipe(
+ Effect.andThen(Deferred.await(finishConnection)),
+ ),
+ });
+​
+ yield* Effect.gen(function* () {
+ const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
+ expect((yield* registry.state(TARGET.environmentId)).phase).toBe("connecting");
+​
+ yield* Deferred.await(connectionStarted);
+ expect((yield* registry.state(TARGET.environmentId)).phase).toBe("connecting");
+ yield* Deferred.succeed(finishConnection, undefined);
+ }).pipe(Effect.provide(harness.layer), Effect.scoped);
+ }),
+ );
+​
it.effect("exposes the current RPC generation to late query subscribers", () =>
Effect.gen(function* () {
const harness = yield* makeHarness([TARGET]);