Skip to content

Commit 2d80905

Browse files
authored
fix: corrects unit calculations in the slow network error message during Test Replay uploads (#31160)
* fix: corrects unit calculations in the slow upload speed error for test replay archive uploads * changelog
1 parent 63a9f88 commit 2d80905

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ _Released 2/25/2025 (PENDING)_
77

88
- 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).
99

10+
**Bugfixes:**
11+
12+
- 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).
13+
1014
**Misc:**
1115

1216
- 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).

packages/errors/__snapshot-html__/CLOUD_PROTOCOL_UPLOAD_STREAM_STALL_FAILURE.html

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/errors/src/errors.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,14 @@ export const AllCypressErrors = {
604604
605605
${fmt.highlightSecondary(error)}`
606606
},
607-
CLOUD_PROTOCOL_UPLOAD_STREAM_STALL_FAILURE: (error: Error & { chunkSizeKB: number, maxActivityDwellTime: number }) => {
608-
const kbpsThreshold = (error.chunkSizeKB * 8) / (error.maxActivityDwellTime / 1000)
607+
CLOUD_PROTOCOL_UPLOAD_STREAM_STALL_FAILURE: (error: Error & { chunkSizeBytes: number, maxActivityDwellTime: number }) => {
608+
const dwellTimeSeconds = error.maxActivityDwellTime / 1000
609+
const kbpsThreshold = (error.chunkSizeBytes / 1024) / dwellTimeSeconds
609610

610611
return errTemplate`\
611612
Warning: We encountered slow network conditions while uploading the Test Replay recording for this spec.
612613
613-
The upload transfer rate fell below ${fmt.highlightSecondary(`${kbpsThreshold}kbps`)} over a sampling period of ${fmt.highlightSecondary(`${error.maxActivityDwellTime}ms`)}.
614+
The upload transfer rate fell below ${fmt.highlightSecondary(`${kbpsThreshold}kbps`)} over a sampling period of ${fmt.highlightSecondary(`${dwellTimeSeconds} seconds`)}.
614615
615616
To prevent long CI execution durations, this Test Replay recording will not be uploaded.
616617

packages/errors/test/unit/visualSnapshotErrors_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,10 @@ describe('visual error templates', () => {
697697
},
698698
CLOUD_PROTOCOL_UPLOAD_STREAM_STALL_FAILURE: () => {
699699
// @ts-expect-error
700-
const err: Error & { chunkSizeKB: number, maxActivityDwellTime: number } = new Error('stream stall')
700+
const err: Error & { chunkSizeBytes: number, maxActivityDwellTime: number } = new Error('stream stall')
701701

702-
err.chunkSizeKB = 64
703-
err.maxActivityDwellTime = 5000
702+
err.chunkSizeBytes = 65536
703+
err.maxActivityDwellTime = 10000
704704

705705
return {
706706
default: [err],

packages/server/lib/cloud/upload/stream_activity_monitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const debugVerbose = Debug('cypress-verbose:server:cloud:stream-activity-monitor
3131
*
3232
*/
3333

34-
const DEFAULT_FS_READSTREAM_CHUNK_SIZE = 64 * 1024 // Kilobytes
34+
const DEFAULT_FS_READSTREAM_CHUNK_SIZE_BYTES = 64 * 1024 // 64 kB
3535

3636
export class StreamActivityMonitor {
3737
private streamMonitor: Transform | undefined
@@ -78,7 +78,7 @@ export class StreamActivityMonitor {
7878
debug('marking activity interval')
7979
clearTimeout(this.activityTimeout)
8080
this.activityTimeout = setTimeout(() => {
81-
this.controller?.abort(new StreamStalledError(this.maxActivityDwellTime, DEFAULT_FS_READSTREAM_CHUNK_SIZE))
81+
this.controller?.abort(new StreamStalledError(this.maxActivityDwellTime, DEFAULT_FS_READSTREAM_CHUNK_SIZE_BYTES))
8282
}, this.maxActivityDwellTime)
8383
}
8484
}

packages/server/lib/cloud/upload/stream_stalled_error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export class StreamStalledError extends Error {
55

66
constructor (
77
public readonly maxActivityDwellTime: number,
8-
public readonly chunkSizeKB: number,
8+
public readonly chunkSizeBytes: number,
99
) {
10-
super(`Stream stalled: failed to transfer ${chunkSizeKB} kilobytes over the previous ${maxActivityDwellTime}ms`)
10+
super(`Stream stalled: failed to transfer ${chunkSizeBytes} bytes over the previous ${maxActivityDwellTime}ms`)
1111
}
1212

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

0 commit comments

Comments
 (0)