Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): one disconnecting client no longer blocks every reconnect #5572

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/5572/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 2 changed files with 102 additions and 4 deletions.

x
0 of 2 viewed, 2 left
65 additions and 0 deletionsapps/server/src/process/externalLauncher.test.tsModified
View file
@@ -2,6 +2,7 @@
import { assert, it } from "@effect/vitest";
import * as ConfigProvider from "effect/ConfigProvider";
import * as Effect from "effect/Effect";
+import * as Fiber from "effect/Fiber";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
@@ -216,6 +217,70 @@
});
​
+// A client that disconnects mid-scan interrupts the shared discovery effect on
+// the connection fiber. The cache must not retain that interrupt: doing so
+// replayed it to every later connect for the whole TTL, so `server.getConfig`
+// failed and no client could reconnect until the server restarted.
+it.effect("rescans after an interrupted discovery instead of caching the interrupt", () => {
+ const fileInfo = { type: "File" } as FileSystem.File.Info;
+ let blockFirstScan = true;
+ let scans = 0;
+ const launcherLayer = ExternalLauncher.layer.pipe(
+ Layer.provide(
+ Layer.mergeAll(
+ FileSystem.layerNoop({
+ // The first scan parks inside `stat` so the interrupt lands while
+ // discovery is in flight, which is what a client disconnecting
+ // mid-connect does to the shared effect.
+ stat: () =>
+ Effect.gen(function* () {