Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need compatibility with cross-env package #71

Closed
tanekim88 opened this issue Jul 5, 2018 · 8 comments · Fixed by #125
Closed

need compatibility with cross-env package #71

tanekim88 opened this issue Jul 5, 2018 · 8 comments · Fixed by #125
Labels

Comments

@tanekim88
Copy link

tanekim88 commented Jul 5, 2018

Thank you for taking time to open a new issue. Please answer a few questions to help us fix it faster. You can delete text that is irrelevant to the issue.

Is this a bug report or a feature request?

Bug
If this is a bug report, please provide as much info as possible

  • version
    1.5
  • platform
    mac
  • expected behavior
    no error after exist
  • actual behavior
    error after test finishes and exits.

-Detail:
I am using Jest library as testing package.
If I use cross-env to define environment variables for both test and start-server, then it will throw errors when the Jest test exists.
My current configuration:
"test": "cross-env NODE_ENV=test jest --forceExist",
"test-server": "cross-env NODE_ENV=test ts-node src/index.ts",
"ci": "start-server-and-test test-server http://localhost:4000 test",

the error message when it exists the test is the following:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! typeorm@0.0.1 test-server: cross-env NODE_ENV=test ts-node src/index.ts
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the typeorm@0.0.1 test-server 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/tanekim/.npm/_logs/2018-07-05T23_57_30_700Z-debug.log

If I remove the keywords cross-env from all lines and then run ci again, then I don't see the error message.
Also, it is a problem with mac, not windows, as I tested.

If this is a new feature request, please describe it below

@bahmutov
Copy link
Owner

hmm, that is interesting, if you can create a tiny reproducible example repo, even with dummy commands, or even better with a fix PR, I would love to fix this

@petermakowski
Copy link

I believe I run into this issue. I created an example repo here: https://github.com/petermakowski/start-server-and-test-cross-env-bug Do you think you'll have some time to look into this @bahmutov ?

@bahmutov
Copy link
Owner

bahmutov commented Nov 1, 2018 via email

jayphelps added a commit to jayphelps/start-server-and-test that referenced this issue Nov 20, 2018
@jayphelps
Copy link
Contributor

jayphelps commented Nov 20, 2018

Issue is because cross-env returns non-zero status code when the process is killed with anything except SIGINT. start-server-and-test uses process.kill() which by default sends SIGTERM.

Solution could be to use SIGINT instead, though of course it could be debatable to some whether cross-env should assume non-zero for SIGTERM. That said, I currently I agree with their behavior and think SIGINT should be sent instead.

I created a PR to address this #125

Cc/ @kentcdodds
kentcdodds/cross-env#177

jayphelps added a commit to jayphelps/start-server-and-test that referenced this issue Nov 20, 2018
bahmutov pushed a commit that referenced this issue Nov 20, 2018
fix: send SIGINT to child processes instead of SIGKILL, fixes #71
@bahmutov
Copy link
Owner

should be published now as version 1.7.10

@bahmutov
Copy link
Owner

🎉 This issue has been resolved in version 1.7.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jayphelps
Copy link
Contributor

@bahmutov thanks for the quick merge and release! ❤️

@christophwolff
Copy link

Ran into the same issue with crossenv + a node server that is running. Only thing that helps is a

process.on('SIGTERM', () => {
  // Clean Express exit for cypress tests
})

In my server.js. I have no clue why.

It is a big nuxt project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants