Skip to content

Commit 1d839c0

Browse files
Merge branch 'develop' into new-chrome-flags-prefs
2 parents f2ce594 + dee4771 commit 1d839c0

File tree

14 files changed

+440
-271
lines changed

14 files changed

+440
-271
lines changed

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ _Released 10/20/2025 (PENDING)_
1414
- Fixed an issue where grouped command text jumps up and down when expanding and collapsing in the command log. Addressed in [#32757](https://github.com/cypress-io/cypress/pull/32757).
1515
- Fixed an issue where command snapshots were not correctly displayed in Studio. Addressed in [#32808](https://github.com/cypress-io/cypress/pull/32808).
1616
- Fixed an issue with grouped console prop items having a hard to read blue color in the console log and duplicate `:` characters being displayed. Addressed in [#32776](https://github.com/cypress-io/cypress/pull/32776).
17+
- Added more context to the error message shown when `cy.prompt()` fails to download. Addressed in [#32822](https://github.com/cypress-io/cypress/pull/32822).
1718

1819
**Misc:**
1920

packages/reporter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@cypress-design/css": "1.2.0",
2020
"@cypress-design/react-button": "^1.11.0",
2121
"@cypress-design/react-icon": "^1.31.0",
22-
"@cypress/react-tooltip": "0.5.3",
22+
"@cypress/react-tooltip": "0.5.4",
2323
"@fontsource/mulish": "4.3.0",
2424
"@fontsource/open-sans": "4.3.0",
2525
"@fortawesome/fontawesome-free": "6.0.0",
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import os from 'os'
2+
import debugModule from 'debug'
3+
import { DEFAULT_ELECTRON_FLAGS } from './util/chromium_flags'
4+
5+
const debug = debugModule('cypress:server:append_electron_switches')
6+
7+
export const appendElectronSwitches = (app: Electron.App) => {
8+
// NOTE: errors are printed in development mode only
9+
try {
10+
// when running inside the electron process, we need to append the default switches immediately
11+
// before the electron browser is launched. Otherwise, there may be some odd behavior.
12+
debug('appending default switches for electron: %o', DEFAULT_ELECTRON_FLAGS)
13+
DEFAULT_ELECTRON_FLAGS.forEach(({ name, value }) => {
14+
value ? app.commandLine.appendSwitch(name, value) : app.commandLine.appendSwitch(name)
15+
})
16+
17+
if (os.platform() === 'linux') {
18+
app.disableHardwareAcceleration()
19+
}
20+
21+
if (process.env.ELECTRON_EXTRA_LAUNCH_ARGS) {
22+
// regex will be used to convert ELECTRON_EXTRA_LAUNCH_ARGS into an array, for example
23+
// input: 'foo --ipsum=0 --bar=--baz=quux --lorem="--ipsum=dolor --sit=amet"'
24+
// output: ['foo', '--ipsum=0', '--bar=--baz=quux', '--lorem="--ipsum=dolor --sit=amet"']
25+
const regex = /(?:[^\s"']+|"[^"]*"|'[^']*')+/g
26+
const electronLaunchArguments = process.env.ELECTRON_EXTRA_LAUNCH_ARGS.match(regex) || []
27+
28+
electronLaunchArguments.forEach((arg) => {
29+
// arg can be just key --disable-http-cache
30+
// or key value --remote-debugging-port=8315
31+
// or key value with another value --foo=--bar=4196
32+
// or key value with another multiple value --foo='--bar=4196 --baz=quux'
33+
const [key, ...value] = arg.split('=')
34+
35+
// because this is an environment variable, everything is a string
36+
// thus we don't have to worry about casting
37+
// --foo=false for example will be "--foo", "false"
38+
if (value.length) {
39+
let joinedValues = value.join('=')
40+
41+
// check if the arg is wrapped in " or ' (unicode)
42+
const isWrappedInQuotes = !!['\u0022', '\u0027'].find(((charAsUnicode) => joinedValues.startsWith(charAsUnicode) && joinedValues.endsWith(charAsUnicode)))
43+
44+
if (isWrappedInQuotes) {
45+
joinedValues = joinedValues.slice(1, -1)
46+
}
47+
48+
app.commandLine.appendSwitch(key, joinedValues)
49+
} else {
50+
app.commandLine.appendSwitch(key)
51+
}
52+
})
53+
}
54+
} catch (e) {
55+
debug('environment error %s', e.message)
56+
}
57+
}

packages/server/lib/cloud/cy-prompt/CyPromptLifecycleManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export class CyPromptLifecycleManager {
8888
const cloudUrl = ctx.cloud.getCloudUrl(cloudEnv)
8989
const cloudHeaders = await ctx.cloud.additionalHeaders()
9090

91+
const lastError = error instanceof AggregateError ? error.errors[error.errors.length - 1] : error
92+
9193
reportCyPromptError({
9294
cloudApi: {
9395
cloudUrl,
@@ -99,15 +101,15 @@ export class CyPromptLifecycleManager {
99101
additionalHeaders: cloudHeaders,
100102
cyPromptHash: this.cyPromptHash,
101103
projectSlug: (await ctx.project.getConfig()).projectId || undefined,
102-
error,
104+
error: lastError,
103105
cyPromptMethod: 'initializeCyPromptManager',
104106
cyPromptMethodArgs: [],
105107
})
106108

107109
// Clean up any registered listeners
108110
this.listeners = []
109111

110-
return { error }
112+
return { error: lastError }
111113
})
112114

113115
this.cyPromptManagerPromise = cyPromptManagerPromise

packages/server/lib/cypress.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require('./environment')
2-
31
// we are not requiring everything up front
42
// to optimize how quickly electron boots while
53
// in dev or linux production. the reasoning is

packages/server/lib/environment.js

Lines changed: 0 additions & 93 deletions
This file was deleted.

packages/server/lib/environment.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pkg from '@packages/root'
2+
import Bluebird from 'bluebird'
3+
4+
export const configureLongStackTraces = (env: string | undefined) => {
5+
// never cut off stack traces
6+
Error.stackTraceLimit = Infinity
7+
8+
Bluebird.config({
9+
// uses cancellation for automation timeouts
10+
cancellation: true,
11+
// enable long stack traces in dev
12+
longStackTraces: env === 'development',
13+
})
14+
}
15+
16+
export const calculateCypressInternalEnv = () => {
17+
// instead of setting NODE_ENV we will
18+
// use our own separate CYPRESS_INTERNAL_ENV so
19+
// as not to conflict with CI providers
20+
21+
// use env from package first
22+
// or development as default
23+
if (!process.env['CYPRESS_INTERNAL_ENV']) {
24+
// @ts-expect-error
25+
return pkg.env !== null && pkg.env !== undefined ? pkg.env : 'development'
26+
}
27+
28+
return process.env['CYPRESS_INTERNAL_ENV']
29+
}

packages/server/start-cypress.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,25 @@ const { telemetry, OTLPTraceExporterCloud } = require('@packages/telemetry')
33
const { apiRoutes } = require('./lib/cloud/routes')
44
const encryption = require('./lib/cloud/encryption')
55

6+
const { calculateCypressInternalEnv, configureLongStackTraces } = require('./lib/environment')
7+
8+
process.env['CYPRESS_INTERNAL_ENV'] = calculateCypressInternalEnv()
9+
configureLongStackTraces(process.env['CYPRESS_INTERNAL_ENV'])
10+
process.env['CYPRESS'] = 'true'
11+
612
// are we in the main node process or the electron process?
713
const isRunningElectron = electronApp.isRunning()
814

915
const pkg = require('@packages/root')
1016

1117
if (isRunningElectron) {
18+
// if we are in the electron process, we need to patch the electron switches before Cypress launches the app
19+
// @see https://www.electronjs.org/docs/latest/api/environment-variables#electron_run_as_node
20+
const { app } = require('electron')
21+
const { appendElectronSwitches } = require('./lib/append_electron_switches')
22+
23+
appendElectronSwitches(app)
24+
1225
// To pass unencrypted telemetry data to an independent open telemetry endpoint,
1326
// disable the encryption header, update the url, and add any other required headers.
1427
// For example:

packages/server/test/spec_helper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable no-console */
2-
require('../lib/environment')
3-
42
const { enable, mockElectron } = require('./mockery_helper')
53

4+
const { configureLongStackTraces } = require('../lib/environment')
5+
6+
configureLongStackTraces()
67
const chai = require('chai')
78

89
chai.use(require('chai-subset'))

0 commit comments

Comments
 (0)