node-gradle / node-gradle/gradle-node-plugin

Gradle process stop doesn't lead to node process stop

Open
#65 29 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

external dependency
Dominant language
Groovy
Stars
677
Forks
120
PR merge metrics
No merged PRs in 30d

Description

Short: stopping gradle execution on Windows from command line by pressing Ctrl-C doesn't lead to stopping node.exe subprocess on Windows.

Steps to reproduce:

  1. Create project with webpack
  2. Configure start at package.json script via:
"scripts": {
    "start": "webpack-dev-server --open --config webpack.dev.js"
  }
  1. Create npmStart task via gradle kts script:
tasks {
    val npmStart by registering(NpmTask::class) {
        /*dependent tasks are skipped for simplification*/
        setArgs(listOf("run", "start"))
    }
}
  1. Start local node server via .\gradlew.bat :npmStart
  2. Wait for process start (web browser opens)
  3. Press Ctrl-C to stop node.exe execution

Expected result:
All child processes under gradle will be stopped.

Actual result:
Node.exe process remains. And this process starts to be zombie, e.g. process without parent.

Hint: probably (I'm not sure, this require testing), NpmTask should be inherited from Exec, not from DefaultTask. It means that args field will be inherited from Exec task, so it will be fully configurable via user. However next Gradle tool will be responsible to stop all child tasks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the NpmTask implementation and examining how it launches the npm run start command on Windows; compare it with the issue's suggested Exec inheritance. Reproduce with .\gradlew.bat :npmStart and Ctrl-C. Done means the node.exe process and its child processes stop without becoming orphaned.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, nodejs
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.