dmtrKovalenko/fff · error

fff_search returned null search result

Error message

fff_search returned null search result

What it means

In the FFI result-unwrapping path for fff_search, the Rust side returns an FffResult envelope whose success flag indicates completion, but its handle field points to the actual FffSearchResult. When success is set yet the handle is null, the envelope contains no usable search result, so this error is raised instead of proceeding to read the struct. It effectively means the native search call completed but failed to produce a result object (e.g. the Rust layer returned a success envelope with an uninitialized/null handle), and the Node wrapper converts it into an err value so callers never see a dangling or empty handle.

Solutions

  1. Rebuild or reinstall the native library to match the JS version (make build)
  2. Retry the search; recreate the finder instance if it persists
  3. Pin package and native binary to the same released version
Defensive patterns

Strategy: try-catch

Try / catch

const res = finder.search(query); if (!res.ok && res.error.includes('null search result')) { /* rebuild native lib / recreate instance */ }

Prevention

When it happens

Trigger: Native allocation failure while building the search result; ABI/struct layout mismatch between JS bindings and the compiled shared library; internal invariant violation in the Rust search path.

Common situations: Running a prebuilt binary that doesn't match the installed JS package version; low-memory environments where native allocation fails.

Related errors


AI-assisted analysis of dmtrKovalenko/fff@7f8537e70f (2026-09-10). Data as JSON: /api/errors/995b8db23d9222d7. Report an issue: GitHub.

Appendix: source

Thrown at packages/fff-node/src/ffi.ts:952

  const [envelope] = restorePointer({
    retType: [FFF_RESULT_STRUCT],
    paramsValue: wrapPointer([rawPtr]),
  }) as unknown as [FffResultRaw];

  const success = envelope.success !== 0;

  if (!success) {
    const errorMsg = readCString(envelope.error) || "Unknown error";
    freeResult(rawPtr);
    return err(errorMsg);
  }

  const handlePtr = envelope.handle;
  // Free the FffResult envelope (does NOT free handle)
  freeResult(rawPtr);

  if (isNullPointer(handlePtr)) {
    return err("fff_search returned null search result");
  }

  // Read FffSearchResult struct
  const [sr] = restorePointer({
    retType: [FFF_SEARCH_RESULT_STRUCT],
    paramsValue: wrapPointer([handlePtr]),
  }) as unknown as [FffSearchResultRaw];

  const count = sr.count;

  // Read location
  let location: Location | undefined;
  if (sr.location_tag === 1) {
    location = { type: "line", line: sr.location_line };
  } else if (sr.location_tag === 2) {
    location = {
      type: "position",
      line: sr.location_line,

View on GitHub (pinned to 7f8537e70f)