Preserve recursion depth when a shorter route is discovered later - #2
Conversation
|
I tested this together with #1 at 7b2420a. The combined code still returned success instead of detecting the broken descendant in the shorter-path regression: URI-only request deduplication discarded the later route before expansion. An integration candidate is available at https://github.com/FloatingPegasus/lychee/tree/fix/recursive-depth-integration. It preserves credit for #1 in a separate integration commit. The additional fix is FloatingPegasus@cdf4bb3: track minimum request depth, allow strictly shorter routes with a finite depth limit, and retain deduplication for equal/deeper routes and unlimited recursion. All 8 local recursive CLI tests pass on the combined candidate, including #1's deduplication and wide-fanout tests and this PR's delayed-shortcut regression. Clippy with warnings denied and cargo fmt checks pass. This PR's branch remains unchanged so you can choose integration order. |
With
--recursive --max-depth=3, a slow shorter route to an already-crawled page can hide a broken descendant that is inside the depth limit. The global visited set remembers that the page was crawled, but not how much depth was available at the time.This changes the crawl record to the smallest observed depth. With a depth limit, a strictly shorter route can expand the page again; equal or longer routes remain suppressed. Unlimited recursion still expands each canonical URL only once.
The local Wiremock regression has these routes:
The shortcut is delayed so the long route reaches the depth boundary first. The test also verifies the observed request ordering. On base
9623a957, Lychee exits 0 and misses/broken.html. With this patch it reports the broken URL and exits 2.Validation in a Linux Rust container:
cargo test --locked -p lychee --features check_example_domains --test cli test_recursive -- --nocapture: 7 passed.cargo clippy --locked -p lychee --all-targets --features check_example_domains -- -D warnings: passed.cargo fmt --all -- --check: passed.Only the local recursion CLI suite was executed, not the entire repository test suite. Cargo also reports an existing future-incompatibility notice for
proc-macro-error2.This is a focused follow-up to lycheeverse#2283, based directly on its current feature branch. I also ran the new regression against the implementation in #1 (
7b2420af); it still exits 0 there. If #1 lands first, itsseen_requestsset will also need to preserve shorter-path depth propagation, so these patches should not be combined without rerunning this regression. This PR does not include or replace that contributor's fan-out/deduplication work.