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: Improved large resource handling #243

Merged
merged 7 commits into from
Jun 6, 2019

Conversation

djones
Copy link
Contributor

@djones djones commented Jun 6, 2019

This PR:

  • Skips resources and snapshots early on that are destined to fail on upload anyway
  • Reduces noise in debug logs with large dom snapshots
  • Debug logs when and why we're skipping a given resource or snapshot

You'll see logs like this in the integration test run:

[percy] snapshot skipped[max_file_size_exceeded]: 'Test case: exceeds-dom-snapshot-size-limit.html'

That is excepted behavior. Graceful handling of a large DOM and warning you about it.

This PR also drops large resources gracefully and early. If you have LOG_LEVEL=debug set you will see in the logs something like this:

[percy] Skipping [max_file_size_exceeded_21141605] [1280 px]: http://localhost:8000/20mb.png

// truncate domSnapshot for the logs if it's very large
let domSnapshotLog = request.body.domSnapshot
if (domSnapshotLog.length > Constants.MAX_LOG_LENGTH) {
domSnapshotLog = domSnapshotLog.substring(0, Constants.MAX_LOG_LENGTH)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you'll like this one @Robdel12. We'll no longer spit out huge logs that are 99% the domSnapshot content.

@djones djones force-pushed the david-jones/skip-large-resources branch from 9301dbb to 45507a7 Compare June 6, 2019 22:27
@djones djones changed the title feat: Improve large resource handling feat: Improved large resource handling Jun 6, 2019
@djones djones marked this pull request as ready for review June 6, 2019 22:56
@djones djones requested a review from Robdel12 June 6, 2019 22:56
@@ -55,6 +56,13 @@ export default class ResponseService extends PercyClientService {
return
}

const responseBodySize = (await response.buffer()).length
if (responseBodySize > Constants.MAX_FILE_SIZE_BYTES) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Per discussion, let's reorganize this to stat the local file copy afterward, instead of reading the buffer and checking it here before writing the local copy (ie. optimize for the 99% case of not skipping, and use stat because it's fast and avoids the double buffer read)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed with 941db82

Copy link
Contributor

@fotinakis fotinakis left a comment

Choose a reason for hiding this comment

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

LGTM 🌮

@djones djones merged commit 4681425 into master Jun 6, 2019
@djones djones deleted the david-jones/skip-large-resources branch June 6, 2019 23:52
djones pushed a commit that referenced this pull request Jun 6, 2019
# [0.7.0](v0.6.0...v0.7.0) (2019-06-06)

### Features

* Improved large resource handling ([#243](#243)) ([4681425](4681425))
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

Successfully merging this pull request may close these issues.

2 participants