Skip to content

Commit

Permalink
feat(deps): update dependency electron to version 12.x 🌟 (#15292)
Browse files Browse the repository at this point in the history
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Zach Bloomquist <git@chary.us>
  • Loading branch information
3 people committed Mar 10, 2021
1 parent c449775 commit b52ac98
Show file tree
Hide file tree
Showing 36 changed files with 181 additions and 380 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm/**/cypress/screenshots
# from example
packages/example/app
packages/example/build
packages/example/cypress
packages/example/cypress/integration

# from server
packages/server/.cy
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.18.3
14.16.0
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ branches:
# https://www.appveyor.com/docs/lang/nodejs-iojs/
environment:
# use matching version of Node.js
nodejs_version: "12.18.3"
nodejs_version: "14.16.0"
# encode secure variables which will NOT be used
# in pull requests
# https://www.appveyor.com/docs/build-configuration/#secure-variables
Expand Down
6 changes: 3 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ executors:
# the Docker image with Cypress dependencies and Chrome browser
cy-doc:
docker:
- image: cypress/browsers:node12.18.3-chrome83-ff77
- image: cypress/browsers:node14.16.0-chrome89-ff77
environment:
PLATFORM: linux

# Docker image with non-root "node" user
non-root-docker-user:
docker:
- image: cypress/browsers:node12.18.3-chrome83-ff77
- image: cypress/browsers:node14.16.0-chrome89-ff77
user: node
environment:
PLATFORM: linux
Expand All @@ -62,7 +62,7 @@ executors:
mac:
macos:
# Executor should have Node >= required version
xcode: "11.3.1"
xcode: "12.2.0"
environment:
PLATFORM: mac

Expand Down
6 changes: 2 additions & 4 deletions cli/__snapshots__/spawn_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ exports['lib/exec/spawn .start forces colors and streams when supported 1'] = {
"MOCHA_COLORS": "1",
"FORCE_STDIN_TTY": "1",
"FORCE_STDOUT_TTY": "1",
"FORCE_STDERR_TTY": "1",
"NODE_OPTIONS": "--max-http-header-size=1048576"
"FORCE_STDERR_TTY": "1"
}

exports['lib/exec/spawn .start does not force colors and streams when not supported 1'] = {
"FORCE_COLOR": "0",
"DEBUG_COLORS": "0",
"FORCE_STDIN_TTY": "0",
"FORCE_STDOUT_TTY": "0",
"FORCE_STDERR_TTY": "0",
"NODE_OPTIONS": "--max-http-header-size=1048576"
"FORCE_STDERR_TTY": "0"
}

exports['lib/exec/spawn .start detects kill signal exits with error on SIGKILL 1'] = `
Expand Down
26 changes: 0 additions & 26 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,35 +281,9 @@ const util = {
.mapValues((value) => { // stringify to 1 or 0
return value ? '1' : '0'
})
.extend(util.getNodeOptions(options))
.value()
},

getNodeOptions (options, nodeVersion) {
if (!nodeVersion) {
nodeVersion = Number(process.versions.node.split('.')[0])
}

if (options.dev && nodeVersion < 12) {
// `node` is used instead of Electron when --dev is passed, so this won't work if Node is too old
debug('NODE_OPTIONS=--max-http-header-size could not be set because we\'re in dev mode and Node is < 12.0.0')

return
}

// https://github.com/cypress-io/cypress/issues/5431
const NODE_OPTIONS = `--max-http-header-size=${1024 ** 2}`

if (_.isString(process.env.NODE_OPTIONS)) {
return {
NODE_OPTIONS: `${NODE_OPTIONS} ${process.env.NODE_OPTIONS}`,
ORIGINAL_NODE_OPTIONS: process.env.NODE_OPTIONS || '',
}
}

return { NODE_OPTIONS }
},

getForceTty () {
return {
FORCE_STDIN_TTY: util.isTty(process.stdin.fd),
Expand Down
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@cypress/listr-verbose-renderer": "^0.4.1",
"@cypress/request": "^2.88.5",
"@cypress/xvfb": "^1.2.4",
"@types/node": "^12.12.50",
"@types/node": "^14.14.31",
"@types/sinonjs__fake-timers": "^6.0.2",
"@types/sizzle": "^2.3.2",
"arch": "^2.2.0",
Expand All @@ -38,7 +38,7 @@
"dayjs": "^1.10.4",
"debug": "4.3.2",
"eventemitter2": "^6.4.3",
"execa": "^5.0.0",
"execa": "4.1.0",
"executable": "^4.1.1",
"extract-zip": "^1.7.0",
"fs-extra": "^9.1.0",
Expand Down
44 changes: 0 additions & 44 deletions cli/test/lib/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ require('../spec_helper')
const os = require('os')
const tty = require('tty')
const snapshot = require('../support/snapshot')
const mockedEnv = require('mocked-env')
const supportsColor = require('supports-color')
const proxyquire = require('proxyquire')
const hasha = require('hasha')
Expand All @@ -12,9 +11,6 @@ const la = require('lazy-ass')
const util = require(`${lib}/util`)
const logger = require(`${lib}/logger`)

// https://github.com/cypress-io/cypress/issues/5431
const expectedNodeOptions = `--max-http-header-size=${1024 * 1024}`

describe('util', () => {
beforeEach(() => {
sinon.stub(process, 'exit')
Expand Down Expand Up @@ -217,7 +213,6 @@ describe('util', () => {
FORCE_COLOR: '1',
DEBUG_COLORS: '1',
MOCHA_COLORS: '1',
NODE_OPTIONS: expectedNodeOptions,
})

util.supportsColor.returns(false)
Expand All @@ -229,46 +224,7 @@ describe('util', () => {
FORCE_STDERR_TTY: '0',
FORCE_COLOR: '0',
DEBUG_COLORS: '0',
NODE_OPTIONS: expectedNodeOptions,
})
})
})

context('.getNodeOptions', () => {
let restoreEnv

afterEach(() => {
if (restoreEnv) {
restoreEnv()
restoreEnv = null
}
})

it('adds required NODE_OPTIONS', () => {
restoreEnv = mockedEnv({
NODE_OPTIONS: undefined,
})

expect(util.getNodeOptions({})).to.deep.eq({
NODE_OPTIONS: expectedNodeOptions,
})
})

it('includes existing NODE_OPTIONS', () => {
restoreEnv = mockedEnv({
NODE_OPTIONS: '--foo --bar',
})

expect(util.getNodeOptions({})).to.deep.eq({
NODE_OPTIONS: `${expectedNodeOptions} --foo --bar`,
ORIGINAL_NODE_OPTIONS: '--foo --bar',
})
})

it('does not return if dev is set and version < 12', () => {
expect(util.getNodeOptions({
dev: true,
}, 11)).to.be.undefined
})
})

Expand Down
6 changes: 3 additions & 3 deletions npm/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"build": "rimraf dist && yarn rollup -c rollup.config.js",
"build-prod": "yarn build",
"cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}",
"cy:open:debug": "NODE_OPTIONS=--max-http-header-size=1048576 node --inspect-brk ../../scripts/start.js --component-testing --project ${PWD}",
"cy:open:debug": "node --inspect-brk ../../scripts/start.js --component-testing --project ${PWD}",
"cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}",
"cy:run:debug": "NODE_OPTIONS=--max-http-header-size=1048576 node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}",
"cy:run:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}",
"pretest": "yarn transpile",
"test": "yarn cy:run",
"transpile": "tsc",
Expand All @@ -29,7 +29,7 @@
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.1.1",
"@types/node": "12.12.50",
"@types/node": "14.14.31",
"@types/semver": "7.3.4",
"babel-loader": "8.0.6",
"css-loader": "2.1.1",
Expand Down
23 changes: 14 additions & 9 deletions npm/react/cypress/component/basic/error-boundary-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ describe('Error Boundary', () => {
})

it('on error, display fallback UI', () => {
try {
mount(
<ErrorBoundary name="ChildWithError">
<ChildWithError />
</ErrorBoundary>,
)
} catch (e) {
// do nothing
}
// Error boundaries do not stop an uncaught error from propagating.
// Cypress will fail on uncaught exceptions by default, so we need to suppress that behavior.
cy.on('uncaught:exception', (err) => {
// Assert that we are only suppressing the default behavior for the error we expect.
expect(err.message.includes('I crashed!')).to.be.true

return false
})

mount(
<ErrorBoundary name="ChildWithError">
<ChildWithError />
</ErrorBoundary>,
)

cy.get('header h1').should('contain', 'Something went wrong.')
cy.get('header h3').should('contain', 'ChildWithError failed to load')
Expand Down
4 changes: 2 additions & 2 deletions npm/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"build": "rimraf dist && yarn rollup -c rollup.config.js",
"build-prod": "yarn build",
"cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}",
"cy:open:debug": "NODE_OPTIONS=--max-http-header-size=1048576 node --inspect-brk ../../scripts/start.js --component-testing --project ${PWD}",
"cy:open:debug": "node --inspect-brk ../../scripts/start.js --component-testing --project ${PWD}",
"cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}",
"cy:run:debug": "NODE_OPTIONS=--max-http-header-size=1048576 node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}",
"cy:run:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}",
"pretest": "yarn transpile",
"test": "yarn cy:run",
"test-ci": "node run-tests.js",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"@types/markdown-it": "0.0.9",
"@types/mini-css-extract-plugin": "0.8.0",
"@types/mocha": "8.0.3",
"@types/node": "12.12.50",
"@types/node": "14.14.31",
"@types/prismjs": "1.16.0",
"@types/ramda": "0.25.47",
"@types/react": "16.9.50",
Expand Down Expand Up @@ -192,7 +192,7 @@
"typescript": "3.7.4"
},
"engines": {
"node": ">=12.18.3",
"node": ">=14.16.0",
"yarn": ">=1.17.3"
},
"productName": "Cypress",
Expand Down
15 changes: 13 additions & 2 deletions packages/driver/src/cypress/cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const setTopOnError = function (Cypress, cy, errors) {
const isSpecError = $errUtils.isSpecError(Cypress.config('spec'), err)

if (isSpecError) {
return curCy.onSpecWindowUncaughtException(handlerType, err)
return curCy.onSpecWindowUncaughtException(handlerType, err, promise)
}

return curCy.onUncaughtException(handlerType, err, promise)
Expand Down Expand Up @@ -1222,13 +1222,24 @@ const create = function (specWindow, Cypress, Cookies, state, config, log) {
snapshots.onBeforeWindowLoad()
},

onSpecWindowUncaughtException (handlerType, err) {
onSpecWindowUncaughtException (handlerType, err, promise) {
err = errors.createUncaughtException('spec', handlerType, err)

const runnable = state('runnable')

if (!runnable) return err

if (config('componentTesting')) {
// in component testing, uncaught exceptions should be catchable, as there is no AUT
const results = Cypress.action('app:uncaught:exception', err, runnable, promise)

// dont do anything if any of our uncaught:exception
// listeners returned false
if (_.some(results, returnedFalse)) {
return
}
}

try {
fail(err)
} catch (failErr) {
Expand Down
4 changes: 0 additions & 4 deletions packages/electron/lib/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ module.exports = {
}
}

// max HTTP header size 8kb -> 1mb
// https://github.com/cypress-io/cypress/issues/76
argv.unshift(`--max-http-header-size=${1024 * 1024}`)

debug('spawning %s with args', execPath, argv)

if (debug.enabled) {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"minimist": "1.2.5"
},
"devDependencies": {
"electron": "11.3.0",
"electron": "12.0.0",
"execa": "4.1.0",
"mocha": "3.5.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/https-proxy/lib/ca.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class CA {
}

writeCAVersion () {
return fs.outputFileAsync(this.getCAVersionPath(), CA_VERSION)
return fs.outputFileAsync(this.getCAVersionPath(), String(CA_VERSION))
}

assertMinimumCAVersion () {
Expand Down
7 changes: 5 additions & 2 deletions packages/https-proxy/lib/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const _ = require('lodash')
const { allowDestroy, connect } = require('@packages/network')
const { allowDestroy, connect, httpUtils } = require('@packages/network')
const debug = require('debug')('cypress:https-proxy')
const https = require('https')
const net = require('net')
Expand Down Expand Up @@ -227,7 +227,10 @@ class Server {

_listenHttpsServer (data) {
return new Promise((resolve, reject) => {
const server = https.createServer(data)
const server = https.createServer({
...data,
...httpUtils.lenientOptions,
})

allowDestroy(server)

Expand Down
5 changes: 2 additions & 3 deletions packages/network/lib/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net from 'net'
import { getProxyForUrl } from 'proxy-from-env'
import url from 'url'
import { createRetryingSocket, getAddress } from './connect'
import { lenientOptions } from './http-utils'

const debug = debugModule('cypress:network:agent')
const CRLF = '\r\n'
Expand Down Expand Up @@ -151,9 +152,7 @@ export class CombinedAgent {

// called by Node.js whenever a new request is made internally
addRequest (req: http.ClientRequest, options: http.RequestOptions, port?: number, localAddress?: string) {
// allow requests which contain invalid/malformed headers
// https://github.com/cypress-io/cypress/issues/5602
req.insecureHTTPParser = true
_.merge(req, lenientOptions)

// Legacy API: addRequest(req, host, port, localAddress)
// https://github.com/nodejs/node/blob/cb68c04ce1bc4534b2d92bc7319c6ff6dda0180d/lib/_http_agent.js#L148-L155
Expand Down
15 changes: 15 additions & 0 deletions packages/network/lib/http-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,18 @@ const NO_BODY_STATUS_CODES = [204, 304]
export function responseMustHaveEmptyBody (req: IncomingMessage, res: IncomingMessage) {
return _.includes(NO_BODY_STATUS_CODES, res.statusCode) || (req.method && req.method.toLowerCase() === 'head')
}

/**
* HTTP options to make Node.js's HTTP libraries behave as leniently as possible.
*
* These should be used whenever Cypress is processing "real-world" HTTP requests - like when setting up a proxy
* server or sending outgoing requests.
*/
export const lenientOptions = {
// increase header buffer for incoming response (ClientRequest) request (Server) headers, from 16KB to 1MB
// @see https://github.com/cypress-io/cypress/issues/76
maxHeaderSize: 1024 ** 2,
// allow requests which contain invalid/malformed headers
// https://github.com/cypress-io/cypress/issues/5602
insecureHTTPParser: true,
}
Loading

0 comments on commit b52ac98

Please sign in to comment.