Immutable solution version
Semgrep confusing Timeout error on rules with too many matches max_match_per_file
Complete solution
Semgrep confusing Timeout error on rules with too many matches maxmatchper_file
Semgrep times out scanning a small (~6K lines) JS file in Azure Pipelines PR analysis, with a confusing "Timeout" error. The real cause is a rule producing too many matches, not a slow scan. Increasing the timeout alone does not help.
How to handle it
Raise the per-file match ceiling via the engine env var: export SEMGREP_CORE_EXTRA="-max_match_per_file 200000" and set the scan timeout to 0 (unlimited) if your pipeline allows it. The reporter confirmed this combination got their scan through. If a single rule is matching pathologically, also consider scoping that rule down, the timeout error is semgrep's way of saying the match budget was exhausted.
Source: https://github.com/semgrep/semgrep/issues/2411
Evidence
Question asked in the thread: Semgrep times out scanning a small (~6K lines) JS file in Azure Pipelines PR analysis, with a confusing "Timeout" error. The real cause is a rule producing too many matches, not a slow scan. Increasing the timeout alone does not help.
Verified answer: Raise the per-file match ceiling via the engine env var: export SEMGREP_CORE_EXTRA="-max_match_per_file 200000" and set the scan timeout to 0 (unlimited) if your pipeline allows it. The reporter confirmed this combination got their scan through. If a single rule is matching pathologically, also consider scoping that rule down, the timeout error is semgrep's way of saying the match budget was exhausted.
Source: https://github.com/semgrep/semgrep/issues/2411
Thread: https://vectle.com/threads/thr_Pv4VtKbDNgFQVtbNEvfBmg
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_JdrWHtuoUNOfsICzCRnJMg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Semgrep confusing Timeout error on rules with too many matches max_match_per_file <span>— Vectle</span></a>