{"record":{"id":"4111e9d261f0d2aa","repo":"dmtrKovalenko/fff","slug":"grep-returned-null-result-4111e9","errorCode":null,"errorMessage":"grep returned null result","messagePattern":"grep returned null result","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/fff-node/src/ffi.ts","lineNumber":882,"sourceCode":"\n  const [envelope] = restorePointer({\n    retType: [FFF_RESULT_STRUCT],\n    paramsValue: wrapPointer([rawPtr]),\n  }) as unknown as [FffResultRaw];\n\n  const success = envelope.success !== 0;\n\n  if (!success) {\n    const errorMsg = readCString(envelope.error) || \"Unknown error\";\n    freeResult(rawPtr);\n    return err(errorMsg);\n  }\n\n  const handlePtr = envelope.handle;\n  freeResult(rawPtr);\n\n  if (isNullPointer(handlePtr)) {\n    return err(\"grep returned null result\");\n  }\n\n  const [gr] = restorePointer({\n    retType: [FFF_GREP_RESULT_STRUCT],\n    paramsValue: wrapPointer([handlePtr]),\n  }) as unknown as [FffGrepResultRaw];\n\n  const count = gr.count;\n  const regexFallbackError = readCString(gr.regex_fallback_error) ?? undefined;\n\n  const items: GrepMatch[] = [];\n  for (let i = 0; i < count; i++) {\n    const rawMatch = callAccessor<FffGrepMatchRaw>(\n      \"fff_grep_result_get_match\",\n      handlePtr,\n      i,\n      FFF_GREP_MATCH_STRUCT,\n    );","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/packages/fff-node/src/ffi.ts#L864-L900","documentation":"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.","triggerScenarios":"liveGrep/multiGrep where the native layer reports success but produced no result object — internal allocation failure or struct mismatch with the loaded native binary.","commonSituations":"ABI mismatch after upgrading the package without rebuilding the native addon; corrupted native state after a prior failed call.","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)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"const res = finder.liveGrep(opts); if (!res.ok && res.error === 'grep returned null result') { /* recreate finder or rebuild native lib */ }","preventionTips":["Upgrade JS package and native binaries atomically","Retry once on null-handle errors before failing hard","Avoid sharing finder instances across threads/workers"],"tags":["node","ffi","null-handle"],"backgroundTag":"null-argument","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"}