Repository navigation
fix: stop analyzers from swallowing the per-file parse timeout - #135
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Dependency analysis can hang forever on a big file, even though there is a 30 s per-file timeout.
TimeoutErrorincall_graph_analyzer.pywas a subclass ofException. The language analyzers wrap many small steps inexcept Exception(for example_extract_call_from_nodein 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 generatesat in "Dependency Analysis" at 100% CPU for hours. Whether it hung depended on luck — on where the alarm landed.Fix
Make
TimeoutErroraBaseException, so only_analyze_code_file(which catches it by name and logs a warning) handles it.Tests
tests/test_parse_timeout.py: an analyzer that loops insideexcept Exceptionis now stopped by the timeout. It fails on main (runs the full 30 s) and passes with the fix.