Skip to content

Commit

Permalink
fix: corrects unit calculations in the slow network error message dur…
Browse files Browse the repository at this point in the history
…ing Test Replay uploads (#31160)

* fix: corrects unit calculations in the slow upload speed error for test replay archive uploads

* changelog
  • Loading branch information
cacieprins authored Feb 25, 2025
1 parent 63a9f88 commit 2d80905
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
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

3 comments on commit 2d80905

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2d80905 Feb 25, 2025

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.1.0/linux-x64/develop-2d809054448f6e51a2577fdf5e0ad9174b49b470/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2d80905 Feb 25, 2025

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.1.0/linux-arm64/develop-2d809054448f6e51a2577fdf5e0ad9174b49b470/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2d80905 Feb 25, 2025

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.1.0/darwin-arm64/develop-2d809054448f6e51a2577fdf5e0ad9174b49b470/cypress.tgz

Please sign in to comment.