✨ Do not wait for remote requests to idle during asset discovery#400
Merged
✨ Do not wait for remote requests to idle during asset discovery#400
Conversation
samarsault
pushed a commit
that referenced
this pull request
Mar 3, 2023
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
As described in #399, when requests will not be captured, they can clog up network idle and cause snapshots to take longer to process. However, if we were to untrack remote requests, as that issue suggests, pages might not yet be ready to snapshot when capturing the DOM ourselves since external resources are sometimes required by sites to load properly.
Instead, this PR adds a new feature to the network idle method to filter requests that are awaited on. This new filter can be used when not capturing our own DOM snapshot to only wait on requests from allowed hostnames.
I added a test for capturing lazy images as a precursor to a new test for not awaiting on remote resources (this test will timeout when failing). Lazy images are used in these tests because non-lazy images are normally awaited on via the document's
loadevent, while lazy images are requested after the document'sloadevent.The test diff looks a little weird because I also removed an older test that was included here for coverage of the
hostnameMatchesfunction. That function now lives in@percy/clientwith its own tests, so the test here was unnecessary.I'm labelling this as an enhancement as oppose to a bugfix since it's not necessarily a bug that we're waiting on all requests from the network, and this fixes #399 by further enhancing how we handle resources.