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

feat: resilient sitemap loading #2619

Merged
merged 9 commits into from
Aug 16, 2024
Merged

Conversation

barjin
Copy link
Contributor

@barjin barjin commented Aug 14, 2024

Adds:

async SitemapRequestList.teardown()

Allows users to signal that they won't need the SitemapRequestList instance anymore (so the sitemap loading can stop and trash all pending URLs). Internally, this unblocks the waiting pushNextUrl calls and allows the runtime environment to terminate correctly.

On-error retries for parseSitemap()

Network errors do not crash the parseSitemap() or SitemapRequestList.load() calls anymore. Instead, the sitemap load is retried (plus, with SitemapRequestList, the URLs aren't duplicated if the error happened somewhere in the middle of the sitemap load).

Parametrizable network timeouts for parseSitemap()

Both parseSitemap() and SitemapRequestList.load() calls now accept got-like timeout object (see more details here). This can help with issues described in #2577 .

Closes #2577
Closes #2617

@barjin barjin added the feature Issues that represent new features or improvements to existing features. label Aug 14, 2024
@barjin barjin requested review from janbuchar and B4nan August 14, 2024 12:18
@barjin barjin self-assigned this Aug 14, 2024
@github-actions github-actions bot added this to the 96th sprint - Tooling team milestone Aug 14, 2024
@github-actions github-actions bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Aug 14, 2024
Copy link
Contributor

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, just a couple of comments on tests. I'll review this more thoroughly when tests pass.

test/core/sitemap_request_list.test.ts Outdated Show resolved Hide resolved
test/core/sitemap_request_list.test.ts Show resolved Hide resolved
Copy link
Contributor

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool stuff!

method: 'GET',
timeout: networkTimeouts,
headers: {
'accept': 'application/xhtml+xml,application/xml,text/plain',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this make a well-behaved server not return a .gz file? I'd say Content negotiation failed in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is (a shortened) version of what regular web browsers send in the accept header. I added a */* directive to allow for any type the server has. The accept-encoding header is something got-scraping sets itself, as it depends on the HTTP client capabilities.

I say let's monitor for errors like this, worst case, we know where to look :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do browsers send that for files that end in .gz as well? It sounds fishy...

packages/utils/src/internals/sitemap.ts Outdated Show resolved Hide resolved
@janbuchar janbuchar self-requested a review August 15, 2024 14:48
@barjin barjin merged commit 1dd7660 into master Aug 16, 2024
9 checks passed
@barjin barjin deleted the feat/resilient-sitemap-loading branch August 16, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issues that represent new features or improvements to existing features. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: SitemapRequestList network error retries
2 participants