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
- Rebuild/reinstall the native library to match the JS layer (make build)
- Retry the grep once — transient native allocation failures can clear
- 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
- Upgrade JS package and native binaries atomically
- Retry once on null-handle errors before failing hard
- Avoid sharing finder instances across threads/workers
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
- fff_create_instance_with returned null handle
- fff_search returned null search result
- fff native library not found. Run `npx @ff-labs/fff-node…
- Unknown error
- fff native library not found. Run `npx @ff-labs/fff-node…
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)