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

fix: corrects unit calculations in the slow network error message during Test Replay uploads #31160

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ _Released 2/25/2025 (PENDING)_

- Firefox versions 135 and up are now automated with [WebDriver BiDi](https://www.w3.org/TR/webdriver-bidi/) instead of [Chrome Devtools Protocol](https://chromedevtools.github.io/devtools-protocol/). Addresses [#30220](https://github.com/cypress-io/cypress/issues/30220).

**Bugfixes:**

- Fixed the calculation of upload throughput units when displaying the 'stream stalled' error message during Test Replay archive uploads. Fixes [#31075](https://github.com/cypress-io/cypress/issues/31075). Addressed in [#31160](https://github.com/cypress-io/cypress/pull/31160).

**Misc:**

- Viewport width, height, and scale now display in a badge above the application under test. The dropdown describing how to set viewport height and width has been removed from the UI. Additionally, component tests now show a notice about URL navigation being disabled in component tests. Addresses [#30999](https://github.com/cypress-io/cypress/issues/30999). Addressed in [#31119](https://github.com/cypress-io/cypress/pull/31119).
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,14 @@ export const AllCypressErrors = {

${fmt.highlightSecondary(error)}`
},
CLOUD_PROTOCOL_UPLOAD_STREAM_STALL_FAILURE: (error: Error & { chunkSizeKB: number, maxActivityDwellTime: number }) => {
const kbpsThreshold = (error.chunkSizeKB * 8) / (error.maxActivityDwellTime / 1000)
CLOUD_PROTOCOL_UPLOAD_STREAM_STALL_FAILURE: (error: Error & { chunkSizeBytes: number, maxActivityDwellTime: number }) => {
const dwellTimeSeconds = error.maxActivityDwellTime / 1000
const kbpsThreshold = (error.chunkSizeBytes / 1024) / dwellTimeSeconds

return errTemplate`\
Warning: We encountered slow network conditions while uploading the Test Replay recording for this spec.

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

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

Expand Down
6 changes: 3 additions & 3 deletions packages/errors/test/unit/visualSnapshotErrors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,10 @@ describe('visual error templates', () => {
},
CLOUD_PROTOCOL_UPLOAD_STREAM_STALL_FAILURE: () => {
// @ts-expect-error
const err: Error & { chunkSizeKB: number, maxActivityDwellTime: number } = new Error('stream stall')
const err: Error & { chunkSizeBytes: number, maxActivityDwellTime: number } = new Error('stream stall')

err.chunkSizeKB = 64
err.maxActivityDwellTime = 5000
err.chunkSizeBytes = 65536
err.maxActivityDwellTime = 10000

return {
default: [err],
Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/cloud/upload/stream_activity_monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const debugVerbose = Debug('cypress-verbose:server:cloud:stream-activity-monitor
*
*/

const DEFAULT_FS_READSTREAM_CHUNK_SIZE = 64 * 1024 // Kilobytes
const DEFAULT_FS_READSTREAM_CHUNK_SIZE_BYTES = 64 * 1024 // 64 kB

export class StreamActivityMonitor {
private streamMonitor: Transform | undefined
Expand Down Expand Up @@ -78,7 +78,7 @@ export class StreamActivityMonitor {
debug('marking activity interval')
clearTimeout(this.activityTimeout)
this.activityTimeout = setTimeout(() => {
this.controller?.abort(new StreamStalledError(this.maxActivityDwellTime, DEFAULT_FS_READSTREAM_CHUNK_SIZE))
this.controller?.abort(new StreamStalledError(this.maxActivityDwellTime, DEFAULT_FS_READSTREAM_CHUNK_SIZE_BYTES))
}, this.maxActivityDwellTime)
}
}
4 changes: 2 additions & 2 deletions packages/server/lib/cloud/upload/stream_stalled_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export class StreamStalledError extends Error {

constructor (
public readonly maxActivityDwellTime: number,
public readonly chunkSizeKB: number,
public readonly chunkSizeBytes: number,
) {
super(`Stream stalled: failed to transfer ${chunkSizeKB} kilobytes over the previous ${maxActivityDwellTime}ms`)
super(`Stream stalled: failed to transfer ${chunkSizeBytes} bytes over the previous ${maxActivityDwellTime}ms`)
}

public static isStreamStalledError (error: Error & {kind?: any}): error is StreamStalledError {
Expand Down
Loading