bahmutov / start-server-and-test

Starts server, waits for URL, then runs test command; when the tests end, shuts down server
MIT License
1.54k stars 95 forks source link

ELIFECYCLE error #199

Open chaselw opened 5 years ago

chaselw commented 5 years ago

Is this a bug report or a feature request? bug report

Running on Windows 10 bash terminal.

Ran with debug mode. Stack trace is:

Test Suites: 4 passed, 4 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        7.336s, estimated 13s
Ran all test suites matching /\\GoldTests\\*/i.
  start-server-and-test getting child processes +9s
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: spawn wmic.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! beaker-ui@1.0.0 test:setSeleniumVar: `cross-env REACT_APP_IS_SELENIUM_TESTING=true DEBUG=start-server-and-test "start-test" "start" "3000" "test:selenium"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the beaker-ui@1.0.0 test:setSeleniumVar script.

scripts I'm running are:

"test:setSeleniumVar": "cross-env REACT_APP_IS_SELENIUM_TESTING=true DEBUG=start-server-and-test",
"test:selenium": "npm test -- /GoldTests/*",
"test:integration": "npm run test:setSeleniumVar start-test start 3000 test:selenium"

package.json:

    "dependencies": {
        "@codewithdan/observable-store": "1.0.20",
        "axios": "0.18.1",
        "file-saver": "2.0.2",
        "react": "16.8.6",
        "react-autosuggest": "9.4.3",
        "react-beautiful-dnd": "10.1.1",
        "react-bootstrap": "1.0.0-beta.9",
        "react-dom": "16.8.6",
        "react-jsonschema-form": "^1.6.1",
        "react-scripts": "3.0.1",
        "selenium-webdriver": "^4.0.0-alpha.4"
    },
    "devDependencies": {
        "@babel/plugin-proposal-class-properties": "^7.5.5",
        "@babel/preset-env": "^7.5.4",
        "@babel/preset-react": "^7.0.0",
        "@types/jest": "^24.0.15",
        "babel-jest": "^24.8.0",
        "babel-plugin-transform-runtime": "^6.23.0",
        "chromedriver": "^73.0.0",
        "cross-env": "^5.2.0",
        "enzyme": "^3.10.0",
        "enzyme-adapter-react-16": "^1.14.0",
        "geckodriver": "^1.16.2",
        "identity-obj-proxy": "^3.0.0",
        "jest": "24.7.1",
        "mocha": "^6.1.4",
        "react-test-renderer": "^16.8.6",
        "selenium-side-runner": "^3.12.1",
        "start-server-and-test": "^1.10.0"
    },

on jenkins got extra stack trace info

13:14:55  { Error: Command failed: /bin/sh -c npm run test:runner
13:14:55      at makeError (/opt/jenkins_slave/workspace/ui-1.0.0-feature-Tardis-5264-E2E/node_modules/start-server-and-test/node_modules/execa/index.js:174:9)
13:14:55      at Promise.all.then.arr (/opt/jenkins_slave/workspace/ui-1.0.0-feature-Tardis-5264-E2E/node_modules/start-server-and-test/node_modules/execa/index.js:278:16)
13:14:55      at process._tickCallback (internal/process/next_tick.js:68:7)
13:14:55    code: 1,
13:14:55    stdout: null,
13:14:55    stderr: null,
13:14:55    failed: true,
13:14:55    signal: null,
13:14:55    cmd: '/bin/sh -c npm run test:runner',
13:14:55    timedOut: false,
13:14:55    killed: false }
chaselw commented 5 years ago

Currently in the package.json of start-server-and-test they rely on "execa": "0.11.0" Latest is 2.0.4. Their latest build mentions "improved windows support". I wonder if updating to the latest version will fix.

ghost commented 5 years ago

Currently in the package.json of start-server-and-test they rely on "execa": "0.11.0" Latest is 2.0.4. Their latest build mentions "improved windows support". I wonder if updating to the latest version will fix.

I'm seeing the exact same outcome on a Mac. My co-worker is not seeing the error on the exact same code base as me and he is running Linux.

chaselw commented 5 years ago

Yeah I didn't update but essentially same thing with me. Seeing the error on my Windows machine but on our devbuild that runs linux it's not a problem. We just ignore the error for now but it would be nice if it wasn't there.

ajkl2533 commented 5 years ago

We have a similar issue, we are using start-server-and-test for starting React SPA before running Cypress tests and when some of the tests fail it doesn't stop correctly and I get this error:

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! ssc-ui-core@1.0.0 cypress:run:junit: `yarn cypress:run --reporter junit --reporter-options mochaFile=test/reports/cypress/[hash].xml`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the ssc-ui-core@1.0.0 cypress:run:junit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/rpodrazky/.npm/_logs/2019-09-16T13_33_31_198Z-debug.log
  start-server-and-test getting child processes +3m
  start-server-and-test stopping child processes +57ms
  start-server-and-test stopping server +1ms

INFO: Gracefully shutting down. Please wait...
{ Error: Command failed: /bin/sh -c npm run cypress:run:junit
    at makeError (/Users/rpodrazky/Documents/PROJECTS/ssc-ui-core/node_modules/start-server-and-test/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/Users/rpodrazky/Documents/PROJECTS/ssc-ui-core/node_modules/start-server-and-test/node_modules/execa/index.js:278:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 2,
  stdout: null,
  stderr: null,
  failed: true,
  signal: null,
  cmd: '/bin/sh -c npm run cypress:run:junit',
  timedOut: false,
  killed: false }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I tried to update to latest version 1.10.2, the error message changed a little bit but it still fails

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ssc-ui-core@1.0.0 cypress:run:junit: `yarn cypress:run --reporter junit --reporter-options mochaFile=test/reports/cypress/[hash].xml`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ssc-ui-core@1.0.0 cypress:run:junit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/rpodrazky/.npm/_logs/2019-09-16T13_40_14_153Z-debug.log
  start-server-and-test getting child processes +39s
  start-server-and-test stopping child processes +56ms
  start-server-and-test stopping server +1ms

INFO: Gracefully shutting down. Please wait...
{ Error: Command failed with exit code 1 (EPERM): npm run cypress:run:junit
    at makeError (/Users/rpodrazky/Documents/PROJECTS/ssc-ui-core/node_modules/start-server-and-test/node_modules/execa/lib/error.js:58:11)
    at handlePromise (/Users/rpodrazky/Documents/PROJECTS/ssc-ui-core/node_modules/start-server-and-test/node_modules/execa/index.js:112:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  command: 'npm run cypress:run:junit',
  exitCode: 1,
  exitCodeName: 'EPERM',
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false,
  signal: undefined }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It happens both locally (MacOS Mojave) and also in CI (Jenkins on Ubuntu)

Scipts I'm running

"cypress:run": "cypress run -e TAGS=\"not @ignore\"",
"cypress:run:junit": "yarn cypress:run --reporter junit --reporter-options mochaFile=test/reports/cypress/[hash].xml",
"cypress:run:ci": "start-server-and-test serve http://localhost:3017 cypress:run:junit",

Package versions

"cypress": "3.3.1",
"cypress-cucumber-preprocessor": "1.11.2",
"serve": "^11.1.0",
"start-server-and-test": "^1.10.2",
grundius commented 5 years ago

We are having the same issue. It works when running it locally on Windows 10, but our CI (Google Cloud Build with a Debian LTS docker image) shows the same error.

Package versions:

"start-server-and-test": "^1.10.6",
"webpack": "^4.35.0",
"webpack-cli": "^3.3.5",
"webpack-dev-server": "^3.7.2",
"cypress": "^3.4.1"

Scripts:

"cypress": "cypress run",
"test:e2e": "start-server-and-test start:mock-firebase http-get://localhost:9000 cypress"

(Note: webpack-dev-server is configured for port 9000)

EDIT: After running in debug mode, I see the error happens when attempting to kill the child processes of the web server. A custom script I now use, based directly on execa v3.2.0 only kills the server itself, and that seems to work. Maybe this issue stems from the task-killing behavior?

jordyvandomselaar commented 5 years ago

@grundius would you mind sharing your fix? We're running into the same issue as well, even on the latest version.

thansber commented 4 years ago

I was having a similar issue, I stumbled upon this other issue #132, and this comment solved my problem.