fix(pi-fff): stop reopening main LMDB envs in aux finders (#700) - #701
Conversation
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
|
@gustav-fff that's fine as a simple fix but I'm wondering if there an easy way to reuse them? |
|
[triage-bot] DIRECTED: yes — easiest reuse is a process-global env cache inside Only per-tracker state that still needs isolation is Alternative if you want it explicit: add Preference? I'll ship whichever you pick — leaning route 1 since it's contained to Honk-Honk 🪿 |
|
[triage-bot] DIRECTED: reuse is possible but not free. Root constraint:
Two options I see:
Option 1 is the right long-term fix if aux finders should benefit from persistent scoring; option 2 is fine if they're truly transient. Which do you want? I'll open a follow-up PR for (1) if you say go. |
|
merging as a hot fix |
|
Need this in stable. I encountered the bug |
|
@gustav-fff isnt it published in 0.10.2? |
|
[triage-bot] DIRECTED: no stable 0.10.2 yet. The merged fix landed on @tifandotme installing Want me to open a release PR for 0.10.2? |
Closes #700
Root cause
AuxFinderPool.acquire(packages/pi-fff/src/aux-finders.ts:71-79) forwarded the main finder'sfrecencyDbPath/historyDbPathinto everyFileFinder.createcall. LMDB envs can only be opened once per process, so the first out-of-workspace search failed withFailed to open frecency database env: environment already open in this program.Fix
Drop
frecencyDbPath/historyDbPathfromAuxOptsand stop passing them when constructing aux finders. Aux finders are transient, per-search pickers and run without persistent frecency/history scoring; the main finder retains ownership of those DBs.Steps to reproduce
Reproducer with
@ff-labs/fff-node(matches the reporter's finding):End-to-end via pi-fff: set
FFF_FRECENCY_DB/FFF_HISTORY_DB, launch@ff-labs/pi-fff@0.10.1in a workspace, then trigger a search that routes to an aux finder (absolute path outside the workspace, or a../elsewhereconstraint). The aux acquire fails withFailed to create aux file finder for <root>: Failed to init frecency db: ....Expected: aux search completes and persistent frecency/history stay enabled on the main finder.
How verified
bun testinpackages/pi-fff/— 45 pass, 0 fail. Added regression testaux finders are created without frecency/history db pathsinpackages/pi-fff/test/aux-pool.test.tsassertingAuxFinderPool.acquirenever forwards DB paths toFileFinder.create.Automated triage via Gustav. Honk-Honk 🪿