Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf: prune per-thread client state and evict idle VCS status cache #15301

ClosedRusiruSadathana(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/15301/headopened View on GitHub

Showing 9 changed files with 38 additions and 15 deletions (loading 6).

x
0 of 9 viewed, 9 left
15 additions and 0 deletionsapps/server/src/vcs/VcsStatusBroadcaster.test.tsModified
View file
@@ -1108,6 +1108,7 @@
yield* Deferred.await(remoteStarted);
assert.equal(state.remoteStatusCalls, 1);
+ assert.equal(state.localStatusCalls, 1);
yield* Scope.close(firstScope, Exit.void);
assert.isTrue(Option.isNone(yield* Deferred.poll(remoteInterrupted)));
@@ -1115,6 +1116,20 @@
yield* Scope.close(secondScope, Exit.void).pipe(Effect.forkScoped);
yield* Deferred.await(remoteInterrupted);
assert.isTrue(Option.isSome(yield* Deferred.poll(remoteInterrupted)));
+​
+ const nextSnapshot = yield* Deferred.make<VcsStatusStreamEvent>();
+ const nextScope = yield* Scope.make();
+ yield* Stream.runForEach(broadcaster.streamStatus({ cwd: "/repo" }), (event) =>
+ event._tag === "snapshot"
+ ? Deferred.succeed(nextSnapshot, event).pipe(Effect.ignore)
+ : Effect.void,
+ ).pipe(Effect.forkIn(nextScope));
+ yield* Deferred.await(nextSnapshot);
+​
+ // Releasing the final poller also evicts its cwd cache entry, so a later
+ // subscription reloads local status instead of retaining state forever.
+ assert.equal(state.localStatusCalls, 2);
+ yield* Scope.close(nextScope, Exit.void);
}).pipe(Effect.provide(testLayer));