cypress-io / netlify-plugin-cypress

Runs Cypress end-to-end tests after Netlify builds the site but before it is deployed
https://www.cypress.io/blog/2020/03/30/run-cypress-tests-on-netlify-using-a-single-line/
MIT License
89 stars 39 forks source link

Started processes on preBuild are not stopped #119

Open spamsch opened 3 years ago

spamsch commented 3 years ago

Versions

Describe the bug Process are not stopped

Logs and screenshots

When using the following configuration the processes are not stopped

[[plugins]]
  package = "netlify-plugin-cypress"

  [plugins.inputs]
    skip = true

  [plugins.inputs.preBuild]
    start = 'npx netlify dev'
    wait-on = 'http://localhost:8888'

  [plugins.inputs.onSuccess]
    record = true

then processes are not stopped

9:57:40 PM: (netlify-plugin-cypress onSuccess completed in 4ms)
9:57:40 PM: 
9:57:40 PM: ** WARNING **
9:57:40 PM: There are some lingering processes even after the build process finished:
9:57:40 PM: 
9:57:40 PM: USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
9:57:40 PM: buildbot    1867  4.8  0.5 24044868 164688 ?     Sl   20:55   0:07 node /opt/buildhome/.nvm/versions/node/v12.18.0/bin/npx netlify dev
9:57:40 PM: buildbot    1880  0.3  0.1 739708 40260 ?        Sl   20:55   0:00 npm
9:57:40 PM: buildbot    1891  0.0  0.0   4512   716 ?        S    20:55   0:00 sh -c vue-cli-service serve
9:57:40 PM: buildbot    1892 29.4  1.4 1243992 451500 ?      Sl   20:55   0:44 node /opt/build/repo/node_modules/.bin/vue-cli-service serve
9:57:40 PM: 
9:57:40 PM: Our builds do not kill your processes automatically, so please make sure
9:57:40 PM: that nothing is running after your build finishes, or it will be marked as
9:57:40 PM: failed since something is still running.
bahmutov commented 3 years ago

We are using utils.run https://github.com/netlify/build/blob/master/packages/run-utils/README.md to execute the server command.

bahmutov commented 3 years ago

I tried it out in https://github.com/cypress-io/netlify-plugin-prebuild-example/pull/54

Advice: instead of using npm run develop command in netlify.toml file, try running the original command. For example

when using npm run develop command the NPM process remains + Gatsby

image

But if we use the direct command, execa can find it and use it

[plugins.inputs.preBuild]
  enable = true
  start = 'gatsby develop'

and only the single deep process remains

image

Of course, it would be nice to resolve it and kill the entire tree of processes. I will look into this in the future, opened a question for Netlify team https://github.com/netlify/build/issues/2371