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

Add option to remove delay on scripting errors #319

Open
AdrianVollmer opened this issue Aug 26, 2024 · 2 comments
Open

Add option to remove delay on scripting errors #319

AdrianVollmer opened this issue Aug 26, 2024 · 2 comments

Comments

@AdrianVollmer
Copy link

AdrianVollmer commented Aug 26, 2024

I'm using elinks to render HTML messages in mutt. Recently, I noticed a delay when opening certain HTML messages. I traced it back to elinks, probably this line:

I also use python hooks for a different purpose, so they simply return the argument in this case, but this triggers the delay.

You can verify like so:

$ rm -rf ~/.config/elinks
# Create file in "wrong" encoding
$ echo '<!DOCTYPE html><html><head><meta charset="utf-8"></head><body>Ö</body></html>' > test.html
$ iconv -f utf8 -t ISO8859-15 test.html > test-iso.html
$ touch .config/elinks/hooks.py
# This is quick
$ time elinks -dump test-iso.html  
elinks -dump test-iso.html  0.02s user 0.01s system 100% cpu 0.032 total
$ mkdir -p ~/.config/elinks && echo 'def pre_format_html_hook(url, html):\n  return html' > ~/.config/elinks/hooks.py
# This is slow
$ time elinks -dump test-iso.html
ELinks: [Python 3.12.5 error] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 62: invalid continuation byte


elinks -dump test-iso.html  0.03s user 0.01s system 1% cpu 3.039 total

I suppose the intent is that the error is loud so that the user notices. However, in this case, I'd rather have it fail silently and see a few corrupt characters. Or bail out entirely and return a non-zero exit code, then I would have found the issue sooner.

$ elinks --version
ELinks 0.18.GIT d501d762eab59cc4e3cd432b25a36a60bc9aec91
Built on Aug 26 2024 10:50:18

What do you think about making that sleep argument as an option, or maybe add an environment variable so I can control this? The error could also go to a log file or something.

(As a workaround I now pipe the file through iconv first to make sure it's always utf8.)

rkd77 added a commit that referenced this issue Aug 26, 2024
…ion. Refs #319

When enabled elinks sleeps 3 seconds in case of error without terminal.
Enabled is the default.
@rkd77
Copy link
Owner

rkd77 commented Aug 26, 2024

Can be like this?

@AdrianVollmer
Copy link
Author

Works for me! Great, thanks

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

No branches or pull requests

2 participants