Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antlr4 isn't robust with slow links. #13

Open
kaby76 opened this issue Jun 5, 2023 · 5 comments
Open

antlr4 isn't robust with slow links. #13

kaby76 opened this issue Jun 5, 2023 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@kaby76
Copy link

kaby76 commented Jun 5, 2023

I've noticed this on my machines and now over in github actions build for grammars-v4. When the link is bad, the antlr4 tool fails.

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/antlr4_tool_runner.py", line 26, in latest_version
    with urlopen(f"https://search.maven.org/solrsearch/select?q=a:antlr4-master+g:org.antlr") as response:
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 504: Gateway Time-out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.11/x64/bin/antlr4", line 8, in <module>
    sys.exit(tool())
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/antlr4_tool_runner.py", line 131, in tool
    args, version = get_version_arg(args)
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/antlr4_tool_runner.py", line 123, in get_version_arg
    version = latest_version()
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/antlr4_tool_runner.py", line 36, in latest_version
    version_dirs = list(filter(lambda directory: re.match(r"[0-9]+\.[0-9]+\.[0-9]+", directory), os.listdir(mvn_repo)))
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.m2/repository/org/antlr/antlr4'
Could not get latest version number, attempting to fall back to latest downloaded version...
Build failed
Build completed, time: 00:01:02.4911135
./fortran/fortran90 failed
finished in 00:01:02.5069344
Write-Error: /home/runner/work/grammars-v4/grammars-v4/_scripts/test.ps1:384
Line |
 384 |      Test-AllGrammars -Target $target -PreviousCommit $pc -CurrentComm …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Failed grammars: ./fortran/fortran90

This is happening because it is trying to get the latest version of the Antlr tool.

with urlopen(f"https://search.maven.org/solrsearch/select?q=a:antlr4-master+g:org.antlr") as response:

I can program around this by looking at the output of the tool and grep'ing for some string that says the link is bad. But, the better way would be to loop over the call (maybe 5 times) and catching link errors.

@claus-topholt-private
Copy link

Still SUPER annoying today, it attempts to get latest version every time and the maven link takes 30 secs to respond 504 bad gateway timeout. Please fix.

@parrt
Copy link
Member

parrt commented Nov 5, 2023

Is this the fix? #11 Actually maybe this fixes it: #9

@parrt parrt added the enhancement New feature or request label Nov 5, 2023
@parrt parrt added this to the 0.2.1 milestone Nov 5, 2023
@parrt
Copy link
Member

parrt commented Nov 5, 2023

0.2.1 released :)

@parrt parrt closed this as completed Nov 5, 2023
@claus-topholt-private
Copy link

claus-topholt-private commented Nov 9, 2023

I'm using the TypeScript target, so ANTLR4 is installed with npm. I continue to see this today when running this:

antlr4 -visitor -Dlanguage=TypeScript ./src/antlr/athenaGrammar.g4

(30 sec delay)

Could not get latest version number, attempting to fall back to latest downloaded version...
Found version '4.13.0', this version may be out of date

Is that not the same problem?

@parrt
Copy link
Member

parrt commented Nov 10, 2023

I didn't check what the time out was... maybe it's thirty seconds? sorry I don't have a huge amount of time to look at this. Actually it looks like that PR set timeout=10. Hmm...

btw antlr4 via npm is not going to be the tool itself just the runtime library for the generated code

@parrt parrt reopened this Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants