Skip to content

fix(parsers): bound the JS and Go parse subprocesses with a timeout - #135

Merged
gadievron merged 1 commit into
masterfrom
fix/parse-subprocess-timeout-js-go
Jul 9, 2026
Merged

fix(parsers): bound the JS and Go parse subprocesses with a timeout#135
gadievron merged 1 commit into
masterfrom
fix/parse-subprocess-timeout-js-go

Conversation

@gadievron

Copy link
Copy Markdown
Collaborator

What

Add a 30-minute timeout to the JavaScript and Go parse subprocesses in core/parser_adapter.py, matching the four other parsers.

Root cause

_parse_javascript and _parse_go call subprocess.run(...) with no timeout=, while _parse_c / _parse_ruby / _parse_php / _parse_zig all pass timeout=1800. When the inner Node/Go parser hangs, the Python parent blocks with no bound for any direct caller of parse_repository (library API, tests, tooling). The four already-timed parsers fail cleanly instead.

How

  • core/parser_adapter.py: add timeout=1800 to the subprocess.run in _parse_javascript and _parse_go, at the same placement and value as the four already-timed parsers.

Regression test

tests/test_parser_adapter_timeout.py monkeypatches subprocess.run to capture the timeout kwarg the parse step passes (asserting JS and Go each pass 1800), plus a parity assertion that every language whose parse runs as a subprocess carries a timeout.

RED on origin/master (98f5504):

$ python -m pytest tests/test_parser_adapter_timeout.py -q
3 failed

GREEN on this branch:

$ python -m pytest tests/test_parser_adapter_timeout.py -q
3 passed

Full parser test suite unchanged vs base (delta is exactly these 3 new tests).

Compatibility / scope

Author notes

  • Implements: the two timeout=1800 lines in _parse_javascript and _parse_go.
  • Input previously handled wrong: a repo whose Node/ts-morph or Go parser hangs (e.g. a pathological generated file) blocked the caller forever; it now fails after 30 minutes with TimeoutExpired.
  • Likely reviewer pushback: "why 1800 / why not also bound npm install?" — 1800 matches the four existing parsers verbatim; npm-install is disclosed above as a separate follow-up to keep this change single-purpose.

🤖 Generated with Claude Code

_parse_javascript and _parse_go called subprocess.run with no timeout, while
_parse_c / _parse_ruby / _parse_php / _parse_zig all pass timeout=1800. A hung
inner Node/Go parser therefore blocked the Python parent indefinitely for any
direct caller of parse_repository (library API, tests, tooling); the four
already-timed parsers fail cleanly instead.

- Add timeout=1800 (30 min) to the subprocess.run in _parse_javascript and
  _parse_go, matching the placement and value of the other four parsers.

Parity/robustness change only. Verified against origin/master (98f5504): analyzer
output is byte-identical with vs without the timeout on a real repo (a non-firing
timeout is a no-op), and a runaway subprocess is killed cleanly with TimeoutExpired
rather than hanging.

Note: PR #98 bounds the OUTER Go-CLI -> python subprocess; this bounds the INNER
python -> node/go parse subprocess one level deeper -- complementary, not redundant
(direct-Python callers get no protection from #98).

Regression test (fails on master, passes here):
  $ python -m pytest tests/test_parser_adapter_timeout.py -q
  3 passed

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gadievron
gadievron merged commit d561fe5 into master Jul 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant