Skip to content

fix: stop analyzers from swallowing the per-file parse timeout - #135

Merged
anhnh2002 merged 1 commit into
mainfrom
fix/parse-timeout-swallowed
Oct 13, 2026
Merged

anhnh2002 merged 1 commit into
mainfrom
fix/parse-timeout-swallowed

Conversation

@anhnh2002

Copy link
Copy Markdown
Collaborator

Problem

Dependency analysis can hang forever on a big file, even though there is a 30 s per-file timeout.

TimeoutError in call_graph_analyzer.py was a subclass of Exception. The language analyzers wrap many small steps in except Exception (for example _extract_call_from_node in the JS analyzer). When the SIGALRM fired inside one of those blocks, the error was caught and logged at debug level. The alarm only fires once, so the analyzer then kept running with no limit.

Seen on a repo with a vendored 5.7 MB mermaid bundle (parser.bundle.js): codewiki generate sat in "Dependency Analysis" at 100% CPU for hours. Whether it hung depended on luck — on where the alarm landed.

Fix

Make TimeoutError a BaseException, so only _analyze_code_file (which catches it by name and logs a warning) handles it.

Tests

  • New tests/test_parse_timeout.py: an analyzer that loops inside except Exception is now stopped by the timeout. It fails on main (runs the full 30 s) and passes with the fix.
  • Full suite: 305 passed.
  • Checked by hand on the real 5.7 MB bundle: it is now skipped after 30 s with the timeout warning.

TimeoutError was an Exception, so when SIGALRM fired inside a language
analyzer's own 'except Exception' block (e.g. JS _extract_call_from_node)
the error was swallowed, the one-shot alarm was spent, and a slow file
such as a 5.7 MB vendored JS bundle hung dependency analysis forever.
Make it a BaseException so only _analyze_code_file catches it.
@anhnh2002
anhnh2002 merged commit 34fc7c3 into main Oct 13, 2026
2 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