feat: allow accepting timeouts#2063
Conversation
|
@yegor256 Wanna take this for a spin? |
|
@cristiklein would it be possible to do this in the |
Just tested and it also works via $ cat blah.md
<http://127.0.0.1:8080>
$ cat lychee.toml
accept = [200, 202, 301, 302, 307, 401, "timeout"]
timeout = 1
$ ./target/debug/lychee --config lychee.toml blah.md
1/1 ━━━━━━━━━━━━━━━━━━━━ Finished extracting links Issues found in 1 input. Find details below.
[blah.md]:
[TIMEOUT] http://127.0.0.1:8080/ | Timeout
🔍 1 Total (in 11s) ✅ 0 OK 🚫 0 Errors ⏳ 1 Timeouts
$ echo $?
0 |
|
Thank you for the PR. As mentioned over on the issue we should not use such magic/sentinel values. Reusing It might be simpler and more straight forward to introduce For example all output formats still show an erroneous run. So the timeouts should maybe be marked as success as early as possible, instead of adding |
|
Thanks for the initiative @cristiklein. It's nice to see someone taking on that task. 😊 I agree with Thomas here. Those special values can cause hard-to-debug edge cases. I should know because we're still dealing with the aftermath of my ad-hoc decisions from the past. 😬 So, yeah, let's make it explicit. The lychee config would then look like accept = [200, 202, 301, 302, 307, 401]
# Accept transient timeouts
accept_timeouts = false |
c0c8921 to
d7ceb7f
Compare
a5cfa23 to
6a8007b
Compare
|
Thanks @mre and @thomas-zahner for the kind words and feedback. I just force-pushed a new PR, which addresses your feedback. Below is an example invocation: $ cat blah.md
<http://127.0.0.1:8080>
$ cat lychee.toml
accept = [200, 202, 301, 302, 307, 401]
accept_timeouts = true
timeout = 1
$ ./target/debug/lychee blah.md
1/1 ━━━━━━━━━━━━━━━━━━━━ Finished extracting links Issues found in 1 input. Find details below.
[blah.md]:
[TIMEOUT] http://127.0.0.1:8080/ (at 1:2) | Timeout
🔍 1 Total (in 11s) ✅ 0 OK 🚫 0 Errors ⏳ 1 Timeouts
$ echo $?
0Let me know what you think. |
|
@cristiklein maybe you can update the title and description of the PR, for clarity? |
|
@cristiklein Cool, that looks better. Also great to see the new test 👍 Now we should think about how to display and output such accepted timeouts. Currently, they are still clearly marked as error. This might be unexpected, though maybe the current behaviour is also fine. But my thinking is that if timeouts are accepted timeouts should probably not be shown as errors, but as successes. So for example the timeouts shouldn't show up in |
|
I tried it out and I noticed that timeouts are still retried even if --accept-timeouts is given. This makes it take more time than necessary. Is this intentional? Re output format, I agree that if timeouts are accepted, they shouldn't be printed amongst the errors. Looking at the related enums, I also think the current But anyway, all that won't be fixed in this PR. In this PR, I guess you would change the lines around where it adds to the error map: |
|
Hi @katrinafyi . Thanks for looking into the PR.
Yes, my intention was for
Just to make sure I understand correctly, do you argue for My thinking is the following: This feature will most likely be used in a CI. In that case, the user might still want TIMEOUT in logs, but they want lychee to return 0, so their CI pipeline continues.
Just to make sure I understand correctly, are you arguing for moving accept logic to
Just to make sure, you propose timeouts to be added to As an alternative, would it make sense to add |
If you run echo https://httpbin.org/delay/2 | cargo run -- - --timeout=1 --max-retries=0 --format jsonthe timeout are added to However, at the moment, printing the timeouts (under the default verbosity) is tied to inclusion in the
Sorry, that paragraph was not necessarily directed to you. It's just an early idea and I'm not arguing for anything concrete. |
|
Thanks @katrinafyi for the feedback.
To make the alternative easier to reason about, I went ahead and moved timeouts into timeout_map as a concrete proposal. See 3f9d495 I also simplified Curious whether this direction makes sense conceptually, especially with regard to output verbosity and backward compatibility. |
There was a problem hiding this comment.
@cristiklein Thank you for updating & improving the tests. I really like the idea of a new timeout_map 👍 This makes the new flag more obvious. It controls how users want to interpret the timeout_map. That's something we could also mention in the flag description.
5136f77 to
b3f7cea
Compare
thomas-zahner
left a comment
There was a problem hiding this comment.
I also suggest a few other improvements in 6dc06e9
Co-authored-by: Thomas Zahner <thomas.zahner@protonmail.ch>
Co-authored-by: Thomas Zahner <thomas.zahner@protonmail.ch>
Co-authored-by: Thomas Zahner <thomas.zahner@protonmail.ch>
Co-authored-by: Thomas Zahner <thomas.zahner@protonmail.ch>
|
Thanks @thomas-zahner . I accepted all your suggestions and made the tests pass again. PTAL. |
Sorry, I noticed this too late. I added those suggestions too and fixed the tests accordingly. |
| BOLD_PINK, | ||
| "Issues found in {} {input}. Find details below.\n\n", | ||
| stats.error_map.len() | ||
| "Issues found in {issues} {input}. Find details below.\n\n", |
There was a problem hiding this comment.
Note that it might be better to make this a user hint in the long run. (not in this PR) We could then take the value of accept_timeouts into account.
|
@cristiklein Thank you for the work. I also really like the new |
And thank you for shepherding this PR. I really liked the infrastructure and tests in lychee, and the good discussions we had. It was fun! |
--accept-timeoutswhich means timeouts are accepted as valid links and lychee exits with 0.lychee.tomlby usingaccept_timeouts = trueThanks to @yegor256, @mre and @thomas-zahner for the kind words and feedback.