{"record":{"id":"38860261c031184c","repo":"can1357/oh-my-pi","slug":"grep-timed-out-after-search-grep-timeout-ms-10","errorCode":null,"errorMessage":"Grep timed out after ${SEARCH_GREP_TIMEOUT_MS / 1000}s; narrow paths or pattern, or scope with `glob` first","messagePattern":"Grep timed out after (.+?)s; narrow paths or pattern, or scope with `glob` first","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/grep.ts","lineNumber":1244,"sourceCode":"\t\t\t\t\t\t\t\t\tcontextBefore: normalizedContextBefore,\n\t\t\t\t\t\t\t\t\tcontextAfter: normalizedContextAfter,\n\t\t\t\t\t\t\t\t\tmaxColumns: DEFAULT_MAX_COLUMN,\n\t\t\t\t\t\t\t\t\tmode: effectiveOutputMode,\n\t\t\t\t\t\t\t\t\tmaxCountPerFile: nativeMaxCountPerFile,\n\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\ttimeoutMs: SEARCH_GREP_TIMEOUT_MS,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tskippedOversizedCount = result.skippedOversized ?? 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (err instanceof Error && /^regex(?: parse)? error/i.test(err.message)) {\n\t\t\t\t\t\tthrow new ToolError(err.message.replace(/^regex(?: parse)? error:?\\s*/i, \"Invalid regex: \"));\n\t\t\t\t\t}\n\t\t\t\t\tif (err instanceof Error && err.message.includes(\"Aborted: Timeout\")) {\n\t\t\t\t\t\tthrow new ToolError(\n\t\t\t\t\t\t\t`Grep timed out after ${SEARCH_GREP_TIMEOUT_MS / 1000}s; narrow paths or pattern, or scope with \\`glob\\` first`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\tlet virtualResult: GrepResult;\n\t\t\t\ttry {\n\t\t\t\t\tvirtualResult = await searchVirtualResources(\n\t\t\t\t\t\tvirtualResources,\n\t\t\t\t\t\tnormalizedPattern,\n\t\t\t\t\t\tignoreCase,\n\t\t\t\t\t\teffectiveMultiline,\n\t\t\t\t\t\tnormalizedContextBefore,\n\t\t\t\t\t\tnormalizedContextAfter,\n\t\t\t\t\t\tINTERNAL_TOTAL_CAP,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {","sourceCodeStart":1226,"sourceCodeEnd":1262,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/grep.ts#L1226-L1262","documentation":"The grep operation exceeded the fixed internal timeout (SEARCH_GREP_TIMEOUT_MS) — usually because the pattern or path scope caused a very large scan. The tool converts the abort into an actionable error suggesting you narrow paths or pattern, or pre-filter with the `glob` option.","triggerScenarios":"grep over a huge directory tree (node_modules, dist, monorepo root) with a broad pattern like \"e\" or \".*\"; pathological regex causing heavy backtracking over many files.","commonSituations":"Forgetting to exclude build/vendor directories in a large repo; searching the workspace root instead of a subdirectory; regex quantifier nesting that scales badly.","solutions":["Narrow `path` to the specific directory or files you care about","Add a `glob` filter (e.g. \"*.ts\") to skip irrelevant files before scanning","Make the pattern more specific (anchor it, add required literals) instead of broad wildcards"],"exampleFix":"// before\nawait grep({ pattern: \"config\", path: \".\" });\n// after\nawait grep({ pattern: \"config\", path: \"src\", glob: \"*.ts\" });","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await grep({ pattern, path: \".\" });\n} catch (err) {\n  if (err instanceof ToolError && err.message.startsWith(\"Grep timed out\")) {\n    return await grep({ pattern, path: \"src\", glob: \"*.ts\" }); // narrower retry\n  } else throw err;\n}","preventionTips":["Always scope large-repo searches with path and/or glob (exclude node_modules, dist)","Prefer specific anchored patterns over broad wildcards to cut scan cost"],"tags":["grep","timeout","performance"],"backgroundTag":"search-timeout","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}