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: Improve UX when Test Replay upload fails due to slow upload #30235

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

cacieprins
Copy link
Contributor

@cacieprins cacieprins commented Sep 12, 2024

  • Closes

Additional details

Cypress monitors the upload of a Test Replay recording. If the upload speed drops below 102.4kbps over a period of five seconds, Cypress terminates the upload so that CI pipelines are not unnecessarily slowed. This value is determined by:

  • The default chunk size for an fs readStream is 64 kilobytes
  • The interval used to determine if an upload stream has stalled is 5 seconds
  • 64 kB * 8 = 512kb; 512kbp / 5s = 102.4kbps

This PR changes that behavior such that:

  • A non-cryptic error message is displayed, providing recommended workarounds
  • App Capture code can provide a default interval value, so this duration can be tweaked without updating the Cypress app
  • Users can override the value with an environment variable
  • Uncategorized errors that occur when uploading a Test Replay recording will display a formatted error message.

Steps to test

  • limit machine bandwidth to lower than ~102kbps and increase the sampling interval to an appropriate amount by setting the CYPRESS_PROTOCOL_UPLOAD_SAMPLING_INTERVAL environment variable. If your bandwidth is set to 56kbps, for example, you should set the sampling interval to at least ten seconds (at 56kbps, it should take just over 9 seconds to transfer 512kb, or 64 kiloBytes)
  • the upload will not be cancelled

How has the user experience changed?

A new stream stall error message:
Screenshot 2024-09-12 at 2 23 37 PM

A new uncategorized error message:
Screenshot 2024-09-12 at 2 27 41 PM

PR Tasks

Comment on lines 579 to 581
Warning: We encountered an error while upload the Test Replay recording of this spec.

These reults will not display Test Replay recordings.
Copy link
Member

Choose a reason for hiding this comment

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

@cacieprins typos

Suggested change
Warning: We encountered an error while upload the Test Replay recording of this spec.
These reults will not display Test Replay recordings.
Warning: We encountered an error while uploading the Test Replay recording of this spec.
These results will not display Test Replay recordings.

Copy link

cypress bot commented Sep 12, 2024

cypress    Run #57146

Run Properties:  status check passed Passed #57146  •  git commit b93916fcbc: Merge branch 'develop' into cacie/9143/stream-stall-enhancements
Project cypress
Branch Review cacie/9143/stream-stall-enhancements
Run status status check passed Passed #57146
Run duration 23m 53s
Commit git commit b93916fcbc: Merge branch 'develop' into cacie/9143/stream-stall-enhancements
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 8
Tests that did not run due to a developer annotating a test with .skip  Pending 1326
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 29395
View all changes introduced in this branch ↗︎
UI Coverage  44.89%
  Untested elements 200  
  Tested elements 167  
Accessibility  91.3%
  Failed rules  5 critical   10 serious   2 moderate   2 minor
  Failed elements 944  

@@ -3049,6 +3051,15 @@ exports['e2e record capture-protocol enabled protocol runtime errors db size too
- Screenshot - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 1/2 /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png
- Test Replay - Failed Uploading after Xm, Ys ZZ.ZZms 2/2 - Spec recording too large: artifact is 1024 bytes, limit is 200 bytes

Warning: We encountered an error while upload the Test Replay recording of this spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

These lines still have the typos in them

Same below also

@cacieprins cacieprins marked this pull request as ready for review September 13, 2024 15:18
@cacieprins cacieprins requested review from AtofStryker, ryanjwilke and ryanthemanuel and removed request for ryanjwilke September 13, 2024 17:26

If this error occurs often, the sampling period may be configured by setting the ${fmt.highlightSecondary('CYPRESS_PROTOCOL_UPLOAD_SAMPLING_INTERVAL')} environment variable to a higher value than ${fmt.stringify(error.maxActivityDwellTime)}.

To prevent long CI executing durations, this Test Replay recording will not be uploaded.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
To prevent long CI executing durations, this Test Replay recording will not be uploaded.
To prevent long CI execution durations, this Test Replay recording will not be uploaded.

Copy link
Member

Choose a reason for hiding this comment

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

@cacieprins This still needs addressing.


The upload transfer rate fell below ${fmt.highlightSecondary(`${kbpsThreshold}kbps`)} over a sampling period of ${fmt.highlightSecondary(`${error.maxActivityDwellTime}ms`)}.

If this error occurs often, the sampling period may be configured by setting the ${fmt.highlightSecondary('CYPRESS_PROTOCOL_UPLOAD_SAMPLING_INTERVAL')} environment variable to a higher value than ${fmt.stringify(error.maxActivityDwellTime)}.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like this might flow better if we rearranged the paragraphs.

Warning...

The upload...

To prevent...

The results for this...

If this error occurs...

@@ -719,6 +730,13 @@ describe('visual error templates', () => {
withSystemError: [aggregateErrorWithSystemError],
}
},
CLOUD_PROTOCOL_UPLOAD_UNKNOWN_ERROR: () => {
const error = new Error('some message')
Copy link
Member

Choose a reason for hiding this comment

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

Will this be updated to be a more specific error message?

console.log('')
errors.warning('CLOUD_PROTOCOL_UPLOAD_NEWORK_FAILURE', error)
}
printProtocolUploadError(error)
Copy link
Member

Choose a reason for hiding this comment

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

nice

@@ -320,7 +322,11 @@ export class ProtocolManager implements ProtocolManagerShape {
debug(`uploading %s to %s with a file size of %s`, filePath, uploadUrl, fileSize)

try {
await putProtocolArtifact(filePath, dbSizeLimit(), uploadUrl)
const samplingInterval = process.env.CYPRESS_TEST_REPLAY_UPLOAD_SAMPLING_INTERVAL ?
Copy link
Member

Choose a reason for hiding this comment

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

What is a user passes 'foo' to this env var, it'd evaluate to NaN, then what?

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.

4 participants