Repository navigation
Closed
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
Not sure
Steps to reproduce
- Open Issues.
- Enter a search and wait for the list to respond.
- Repeat with several different searches.
- Leave Issues without reloading T3 Code.
Expected behavior
Once a search is no longer in use, its request can be released.
Actual behavior
T3 Code keeps every distinct search request in memory for the session.
Impact
Minor bug or occasional failure. Anyone who searches or changes filters repeatedly accumulates more retained requests over a long session.
Version or commit
main at 3e1b7c4e93. The cause is at packages/client-runtime/src/state/issues.ts:223.
Environment
Linux x64, the repository's own tests.
Logs or stack traces
historical issue searches retained after closing: expected 3 to be +0Automated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/packages/client-runtime/src/state/issues.test.ts b/packages/client-runtime/src/state/issues.test.ts
index cc4bcb8eb1..b26a789706 100644
--- a/packages/client-runtime/src/state/issues.test.ts
+++ b/packages/client-runtime/src/state/issues.test.ts
@@ -1,7 +1,25 @@
-import type { IssueComment, IssueListEntry, IssueTrackerKind, ProjectId } from "@t3tools/contracts";
+// @effect-diagnostics nodeBuiltinImport:off - The retention test forces garbage collection in Node.
+import { setImmediate } from "node:timers/promises";
+import * as NodeV8 from "node:v8";
+import * as NodeVM from "node:vm";
+import {
+ EnvironmentId,
+ type IssueComment,
+ type IssueListEntry,
+ type IssueListResult,
+ type IssueTrackerKind,
+ type ProjectId,
+} from "@t3tools/contracts";
+import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
import { describe, expect, it } from "vite-plus/test";
-import { issueEntryKey, mergeIssueListPage, prependIssueComments } from "./issues.ts";
+import {
+ createMergedIssueListAtoms,
+ issueEntryKey,
+ mergeIssueListPage,
+ prependIssueComments,
+ type IssueListTarget,
+} from "./issues.ts";
function entry(overrides: Partial<IssueListEntry> & { key: string }): IssueListEntry {
return {
@@ -69,3 +87,44 @@ describe("prependIssueComments", () => {
expect(prependIssueComments(current, older).map((c) => c.id)).toEqual(["c1", "c2", "c3", "c4"]);
});
});
+
+describe("createMergedIssueListAtoms", () => {
+ it("releases historical search targets when the list closes", async () => {
+ NodeV8.setFlagsFromString("--expose-gc");
+ const gc = NodeVM.runInNewContext("gc") as () => void;
+ const answer: IssueListResult = {
+ viewers: {},
+ trackers: [],
+ entries: [],
+ errors: [],
+ nextCursors: {},
+ };
+ const listings = createMergedIssueListAtoms(
+ () => Atom.make(AsyncResult.success(answer)),
+ String,
+ );
+ const registry = AtomRegistry.make();
+ const environmentId = EnvironmentId.make("environment");
+ try {
+ const historical = ["search-one", "search-two", "search-three"].map((query) => {
+ const targets = [
+ { environmentId, input: { state: "open", query } },
+ ] satisfies IssueListTarget[];
+ const close = registry.mount(listings.atom(targets));
+ close();
+ return new WeakRef(targets);
+ });
+ // Let the registry remove all three unmounted queries and the WeakRefs leave their creation job.
+ await setImmediate();
+ gc();
+
+ listings.refreshEnvironment(registry, environmentId);
+ expect(
+ historical.filter((target) => target.deref() !== undefined).length,
+ "historical issue searches retained after closing",
+ ).toBe(0);
+ } finally {
+ registry.dispose();
+ }
+ });
+});cd packages/client-runtime && pnpm exec vp test run src/state/issues.test.tsWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Activity