Compare commits

...

1 Commits

Author SHA1 Message Date
gustav-fff be70ea96b6 fix(pi-fff): stop reopening main LMDB envs in aux finders (#700)
LMDB envs may only be opened once per process. AuxFinderPool was forwarding
the main finder's frecencyDbPath / historyDbPath into every aux FileFinder,
so the first out-of-workspace search failed with
"environment already open in this program".

Aux finders are transient and per-search; they run without persistent
frecency/history scoring.

Closes #700
2026-07-22 14:16:42 -07:00
3 changed files with 25 additions and 10 deletions
+3 -4
View File
@@ -14,8 +14,6 @@ interface AuxPicker {
}
export interface AuxOpts {
frecencyDbPath?: string;
historyDbPath?: string;
enableFsRootScanning: boolean;
}
@@ -69,10 +67,11 @@ export class AuxFinderPool {
}
const { FileFinder } = await loadSdk();
// LMDB env can only be opened once per process; the main finder already
// owns the frecency/history DBs. Aux finders are transient and run without
// persistent scoring — see issue #700.
const result = FileFinder.create({
basePath: maybeRoot,
frecencyDbPath: this.opts.frecencyDbPath,
historyDbPath: this.opts.historyDbPath,
aiMode: true,
enableHomeDirScanning: true,
enableFsRootScanning: this.opts.enableFsRootScanning,
-2
View File
@@ -344,8 +344,6 @@ export default function fffExtension(pi: ExtensionAPI) {
}
let auxPool = new AuxFinderPool({
frecencyDbPath,
historyDbPath,
enableFsRootScanning,
});
+22 -4
View File
@@ -8,6 +8,7 @@ interface MockFinder {
}
const created: MockFinder[] = [];
const createOptions: Record<string, unknown>[] = [];
function createMockFinder(basePath: string): MockFinder {
const finder: MockFinder = {
@@ -24,10 +25,13 @@ function createMockFinder(basePath: string): MockFinder {
const finderModule = {
FileFinder: {
create: (options: { basePath: string }) => ({
ok: true,
value: createMockFinder(options.basePath),
}),
create: (options: Record<string, unknown>) => {
createOptions.push(options);
return {
ok: true,
value: createMockFinder(options.basePath as string),
};
},
},
};
@@ -38,6 +42,7 @@ const { AuxFinderPool } = await import("../src/aux-finders");
function makePool() {
created.length = 0;
createOptions.length = 0;
return new AuxFinderPool({ enableFsRootScanning: false });
}
@@ -86,4 +91,17 @@ describe("AuxFinderPool covering reuse", () => {
expect(other.root).toBe("/a/b");
expect(created.length).toBe(2);
});
// Regression for #700: aux finders must not reopen the main frecency/history
// LMDB envs, or heed fails with "environment already open in this program".
test("aux finders are created without frecency/history db paths", async () => {
const pool = makePool();
await pool.acquire("/a/b/c");
await pool.acquire("/x/y");
expect(createOptions.length).toBe(2);
for (const opts of createOptions) {
expect(opts.frecencyDbPath).toBeUndefined();
expect(opts.historyDbPath).toBeUndefined();
}
});
});