Skip to content

Commit

Permalink
Revert "Always pass NODE_OPTIONS with max-http-header-size (#5452)"
Browse files Browse the repository at this point in the history
This reverts commit 978d97e.
  • Loading branch information
flotwig committed Oct 29, 2019
1 parent 7be840e commit ead7aa9
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 182 deletions.
18 changes: 0 additions & 18 deletions cli/__snapshots__/spawn_spec.js

This file was deleted.

2 changes: 1 addition & 1 deletion cli/lib/exec/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = {
}

const { onStderrData, electronLogging } = overrides
const envOverrides = util.getEnvOverrides(options)
const envOverrides = util.getEnvOverrides()
const electronArgs = _.clone(args)
const node11WindowsFix = isPlatform('win32')

Expand Down
28 changes: 1 addition & 27 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const util = {
return isCi
},

getEnvOverrides (options = {}) {
getEnvOverrides () {
return _
.chain({})
.extend(util.getEnvColors())
Expand All @@ -193,35 +193,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 when --dev is passed, so this won't work if Node is too old
logger.warn('(dev-mode warning only) NODE_OPTIONS=--max-http-header-size could not be set. See https://github.com/cypress-io/cypress/pull/5452')

return
}

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

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
18 changes: 15 additions & 3 deletions cli/test/lib/exec/spawn_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ require('../../spec_helper')
const _ = require('lodash')
const cp = require('child_process')
const os = require('os')
const snapshot = require('snap-shot-it')
const tty = require('tty')
const path = require('path')
const EE = require('events')
Expand Down Expand Up @@ -288,7 +287,14 @@ describe('lib/exec/spawn', function () {

return spawn.start([], { env: {} })
.then(() => {
snapshot(cp.spawn.firstCall.args[2].env)
expect(cp.spawn.firstCall.args[2].env).to.deep.eq({
FORCE_COLOR: '1',
DEBUG_COLORS: '1',
MOCHA_COLORS: '1',
FORCE_STDERR_TTY: '1',
FORCE_STDIN_TTY: '1',
FORCE_STDOUT_TTY: '1',
})
})
})

Expand Down Expand Up @@ -320,7 +326,13 @@ describe('lib/exec/spawn', function () {

return spawn.start([], { env: {} })
.then(() => {
snapshot(cp.spawn.firstCall.args[2].env)
expect(cp.spawn.firstCall.args[2].env).to.deep.eq({
FORCE_COLOR: '0',
DEBUG_COLORS: '0',
FORCE_STDERR_TTY: '0',
FORCE_STDIN_TTY: '0',
FORCE_STDOUT_TTY: '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
4 changes: 4 additions & 0 deletions packages/electron/lib/electron.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ module.exports = {
if opts.inspectBrk
argv.unshift("--inspect-brk=5566")

## 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
11 changes: 5 additions & 6 deletions packages/server/__snapshots__/4_xhr_spec.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ exports['e2e xhr / passes'] = `
✓ does not inject into json's contents from http server even requesting text/html
✓ does not inject into json's contents from file server even requesting text/html
✓ works prior to visit
✓ can stub a 100kb response
server with 1 visit
✓ response body
✓ request body
✓ aborts
9 passing
8 passing
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 9
│ Passing: 9
│ Tests: 8
│ Passing: 8
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
Expand All @@ -61,9 +60,9 @@ exports['e2e xhr / passes'] = `
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ xhr_spec.coffee XX:XX 9 9 - - - │
│ ✔ xhr_spec.coffee XX:XX 8 8 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 9 9 - - -
✔ All specs passed! XX:XX 8 8 - - -
`
13 changes: 5 additions & 8 deletions packages/server/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// if running in production mode (CYPRESS_ENV)
// all transpile should have been done already
// and these calls should do nothing
require('@packages/ts/register')
require('@packages/coffee/register')

require('./lib/util/reset_node_options').reset()

// override tty if we're being forced to
require('./lib/util/tty').override()

Expand All @@ -17,6 +9,11 @@ if (process.env.CY_NET_PROFILE && process.env.CYPRESS_ENV) {

process.env.UV_THREADPOOL_SIZE = 128
require('graceful-fs').gracefulify(require('fs'))
// if running in production mode (CYPRESS_ENV)
// all transpile should have been done already
// and these calls should do nothing
require('@packages/ts/register')
require('@packages/coffee/register')

require && require.extensions && delete require.extensions['.litcoffee']
require && require.extensions && delete require.extensions['.coffee.md']
Expand Down
17 changes: 0 additions & 17 deletions packages/server/lib/util/reset_node_options.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/server/test/e2e/4_xhr_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ describe "e2e xhr", ->
spec: "xhr_spec.coffee"
snapshot: true
expectedExitCode: 0
useCli: true
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,6 @@ describe "xhrs", ->
it "works prior to visit", ->
cy.server()

## https://github.com/cypress-io/cypress/issues/5431
it "can stub a 100kb response", (done) ->
body = 'X'.repeat(100 * 1024)

cy.server()
cy.route({
method: 'POST'
url: '/foo'
response: {
'bar': body
}
})

cy.visit("/index.html")
.then (win) ->
xhr = new win.XMLHttpRequest
xhr.open("POST", "/foo")
xhr.send()

finish = ->
expect(xhr.status).to.eq(200)
expect(xhr.responseText).to.include(body)
done()

xhr.onload = finish
xhr.onerror = finish

describe "server with 1 visit", ->
before ->
cy.visit("/xhr.html")
Expand Down

0 comments on commit ead7aa9

Please sign in to comment.