feat(grep): add timeout support with 60s default to prevent hangs when with very big directories #5096
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Grep tool hangs indefinitely when searching large directories like node_modules because there's no timeout.
I've been using a custom made tool called 'SafeGrep' in my personal plugin (oh-my-opencode) that has hard-limit timeout thing, but figured this would be more useful in core.
Followed Bash tool's implementation and style:
I assumed there would be related issues, but couldn't find any. This was quite annoying in my environment so I thought it was worth fixing—but if this is just my setup or if this PR is heading in the wrong direction, I'd appreciate any feedback!