dmtrKovalenko/fff · error

grep returned null result

Error message

grep returned null result

What it means

After a successful grep envelope, parseGrepResult expects the handle field to point at an FffGrepResult struct. A NULL handle despite success is a native-side invariant violation, so the binding rejects it with this message instead of dereferencing null.

Solutions

  1. Rebuild/reinstall the native library to match the JS layer (make build)
  2. Retry the grep once — transient native allocation failures can clear
  3. Upgrade both the JS package and native binaries together (same version)
Defensive patterns

Strategy: try-catch

Try / catch

const res = finder.liveGrep(opts); if (!res.ok && res.error === 'grep returned null result') { /* recreate finder or rebuild native lib */ }

Prevention

When it happens

Trigger: liveGrep/multiGrep where the native layer reports success but produced no result object — internal allocation failure or struct mismatch with the loaded native binary.

Common situations: ABI mismatch after upgrading the package without rebuilding the native addon; corrupted native state after a prior failed call.

Related errors


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

Appendix: source

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

  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;
  freeResult(rawPtr);

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

  const [gr] = restorePointer({
    retType: [FFF_GREP_RESULT_STRUCT],
    paramsValue: wrapPointer([handlePtr]),
  }) as unknown as [FffGrepResultRaw];

  const count = gr.count;
  const regexFallbackError = readCString(gr.regex_fallback_error) ?? undefined;

  const items: GrepMatch[] = [];
  for (let i = 0; i < count; i++) {
    const rawMatch = callAccessor<FffGrepMatchRaw>(
      "fff_grep_result_get_match",
      handlePtr,
      i,
      FFF_GREP_MATCH_STRUCT,
    );

View on GitHub (pinned to 7f8537e70f)