{"record":{"id":"362cc366d5056d65","repo":"dmtrKovalenko/fff","slug":"searchresult-error","errorCode":null,"errorMessage":"searchResult.error","messagePattern":"searchResult\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/pi-fff/src/index.ts","lineNumber":1093,"sourceCode":"      const effectiveLimit = resumed\n        ? resumed.pageSize\n        : Math.max(1, params.limit ?? DEFAULT_FIND_LIMIT);\n\n      const query = resumed\n        ? resumed.query\n        : aux && \"query\" in aux\n          ? (aux as { query: string }).query\n          : buildQuery(params.path, params.pattern, params.exclude, activeCwd);\n\n      const pattern = resumed ? resumed.pattern : params.pattern;\n      const pageIndex = resumed?.nextPageIndex ?? 0;\n      const auxRoot = resumed?.auxRoot ?? aux?.root;\n\n      const searchResult = picker.fileSearch(query, {\n        pageIndex,\n        pageSize: effectiveLimit,\n      });\n      if (!searchResult.ok) throw new Error(searchResult.error);\n\n      const result = searchResult.value;\n      const formatted = formatFindOutput(result, effectiveLimit, pattern);\n      let output = formatted.output;\n\n      // Infer hasMore: native fileSearch fills pageSize when more results\n      // exist, so if we got a full page AND totalMatched exceeds what we've\n      // shown so far there's another page to fetch.\n      const shownSoFar = pageIndex * effectiveLimit + result.items.length;\n      const hasMore =\n        result.items.length >= effectiveLimit && result.totalMatched > shownSoFar;\n\n      const notices: string[] = [];\n      if (formatted.weak && formatted.shownCount > 0)\n        notices.push(\n          `Query \"${pattern}\" produced only weak scattered fuzzy matches. Output capped at ${formatted.shownCount}/${result.totalMatched}.`,\n        );\n","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/packages/pi-fff/src/index.ts#L1075-L1111","documentation":"The picker's `fileSearch` returns a result object { ok, error?, value? }; the tool throws the error string when `ok` is false. This wraps native file-index search failures — index not ready, destroyed picker, or internal native errors.","triggerScenarios":"Calling find while the native index is still being built or has been destroyed; internal failure in the native fileSearch implementation; querying with a malformed query built from path+pattern+exclude constraints.","commonSituations":"Searching immediately after session start before the initial scan populates the index; a picker destroyed by a cwd change mid-search; very large home-dir scans hitting limits.","solutions":["Wait for initial indexing to finish (scan progress) before searching","Retry the find — transient index states often resolve after the watcher settles","Simplify the query/pattern/exclude combination if the error points at query construction","Rebuild the native binary if errors persist across queries"],"exampleFix":"// before\nawait picker.fileSearch(query, ...) // immediately after startSession, scan incomplete\n\n// after\nawait fff.waitForScan(); // or retry until index ready\nawait picker.fileSearch(query, ...)","handlingStrategy":"retry","validationCode":"// wait for index readiness if exposed\nawait fff.waitForScan?.();","typeGuard":null,"tryCatchPattern":"try { await findTool.execute(id, params, signal); } catch (e) { if (indexWarmingUp) return retryWithBackoff(); throw e; }","preventionTips":["Wait for the initial scan to settle before searching","Don't change cwd mid-search (destroy/recreate cycle)","Retry transient failures with backoff"],"tags":["find","index","native"],"backgroundTag":"api-error-response","analyzedSha":"7f8537e70f0ea1210f9acbbfc4640141105cdc78","analyzedAt":"2026-09-10T07:26:53.407Z","contentChangedAt":"2026-09-10T07:26:53.407Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}