Files
cypress/packages/server/index.js
T
Zach Bloomquist 47410d50e5 Fix "Parse Error" when performing HTTP requests (#5988)
* Detect if NODE_OPTIONS are present in binary; if not, respawn

* Always reset NODE_OPTIONS, even if no ORIGINAL_

Co-authored-by: Andrew Smith <andrew@andrew.codes>

* Exit with correct code # from stub process

* Clean up based on Brian's feedback

* how process.versions is null, i have no idea, but it is

* add repro for invalid header char

* Always pass NODE_OPTIONS with max-http-header-size (#5452)

* cli: set NODE_OPTIONS=--max-http-header-size=1024*1024 on spawn

* electron: remove redundant max-http-header-size

* server: add useCli option to make e2e tests go thru cli

* server: add test for XHR with body > 100kb via CLI

* clean up conditional

* cli: don't pass --max-http-header-size in dev w node < 11.10

* add original_node_options to restore o.g. user node_options

* force no color

* Revert "Use websockets to stub large XHR response bodies instead of hea… (#5525)"

This reverts commit 249db45363.

* fix yarn.lock

* update 4_xhr_spec snapshot

* make 6_visit_spec reproduce invalid header char error

* pass --http-parser=legacy

* still set headers if an ERR_INVALID_CHAR is raised

* add --http-parser=legacy in some more places

* update http_requests_spec

* readd spawn_spec

* improve debug logging

* remove unnecessary changes

* cleanup

* revert yarn.lock to develop

* use cp.spawn, not cp.fork

to work around the Electron patch: https://github.com/electron/electron/blob/39baf6879011c0fe8cc975c7585567c7ed0aeed8/patches/node/refactor_alter_child_process_fork_to_use_execute_script_with.patch

Co-authored-by: Andrew Smith <andrew@andrew.codes>
2020-03-18 17:26:22 -04:00

57 lines
1.8 KiB
JavaScript

// override tty if we're being forced to
require('./lib/util/tty').override()
const electronApp = require('./lib/util/electron-app')
// are we in the main node process or the electron process?
const isRunningElectron = electronApp.isRunning()
if (process.env.CY_NET_PROFILE && isRunningElectron) {
const netProfiler = require('./lib/util/net_profiler')()
process.stdout.write(`Network profiler writing to ${netProfiler.logPath}\n`)
}
process.env.UV_THREADPOOL_SIZE = 128
require('graceful-fs').gracefulify(require('fs'))
// if running in production mode (CYPRESS_INTERNAL_ENV)
// all transpile should have been done already
// and these calls should do nothing
require('@packages/ts/register')
require('@packages/coffee/register')
if (isRunningElectron) {
require('./lib/util/process_profiler').start()
}
require && require.extensions && delete require.extensions['.litcoffee']
require && require.extensions && delete require.extensions['.coffee.md']
// warn when deprecated callback apis are used in electron
// https://github.com/electron/electron/blob/master/docs/api/process.md#processenablepromiseapis
process.enablePromiseAPIs = process.env.CYPRESS_INTERNAL_ENV !== 'production'
// don't show any electron deprecation warnings in prod
process.noDeprecation = process.env.CYPRESS_INTERNAL_ENV === 'production'
// always show stack traces for Electron deprecation warnings
process.traceDeprecation = true
require('./lib/util/suppress_unauthorized_warning').suppress()
function launchOrFork () {
const nodeOptions = require('./lib/util/node_options')
if (nodeOptions.needsOptions()) {
// https://github.com/cypress-io/cypress/pull/5492
return nodeOptions.forkWithCorrectOptions()
}
nodeOptions.restoreOriginalOptions()
module.exports = require('./lib/cypress').start(process.argv)
}
launchOrFork()