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

Wrongful ELIFECYCLE error on program termination  #7164

Closed
2 of 4 tasks
yanickrochon opened this issue Oct 5, 2023 · 9 comments · Fixed by pnpm/npm-lifecycle#41
Closed
2 of 4 tasks

Wrongful ELIFECYCLE error on program termination  #7164

yanickrochon opened this issue Oct 5, 2023 · 9 comments · Fixed by pnpm/npm-lifecycle#41

Comments

@yanickrochon
Copy link

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

8.8.0

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI, Hooks

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

  1. Create a new Turborepo project
  2. Create a Next.js app
  3. Launch app through turbo
  4. Exit app through CTRL+C

Describe the Bug

When launching pnpm next dev, then CTRL+C, no error is emitted. However launching through turbo, the signal received is correct, SIGINT, however pnpm ignores it.

The following code is found in dist/pnpm.cjs, line 98629 (I cannot find that code in this repository)

      proc.on("close", (code, signal) => {
        opts.log.silly("lifecycle", logid(pkg, stage), "Returned: code:", code, " signal:", signal);
        let err;
        if (signal) {
          err = new PnpmError("CHILD_PROCESS_FAILED", `Command failed with signal "${signal}"`);
          process.kill(process.pid, signal);
        } else if (code) {
          err = new PnpmError("CHILD_PROCESS_FAILED", `Exit status ${code}`);
          err.errno = code;
        }
        procError(err);
      });

The signal received is SIGINT, which is correct, and the code is null, which also correct. However, the condition ignores the signal and creates a CHILD_PROCESS_FAILED regardless of it's value.

Expected Behavior

When pressing CTRL+C, pnpm should not throw an error.

Which Node.js version are you using?

18.15.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

@Stanzilla
Copy link

ah there we go, here i was blaming turborepo for that

@yanickrochon
Copy link
Author

The error is here, in the @pnpm/npm-lifecycle dependency, and the fix is to replace the condition to

if (signal && signal !== "SIGINT") {

yanickrochon pushed a commit to yanickrochon/npm-lifecycle that referenced this issue Oct 11, 2023
When a child process sends the INT signal, pnpm should not assume child failed to terminate

Closes pnpm/pnpm#7164
yanickrochon pushed a commit to yanickrochon/npm-lifecycle that referenced this issue Oct 11, 2023
When a child process sends the INT signal, pnpm should not assume child failed to terminate

Closes pnpm/pnpm#7164
yanickrochon pushed a commit to yanickrochon/npm-lifecycle that referenced this issue Oct 11, 2023
When a child process sends the INT signal, pnpm should not assume child failed to terminate

Closes pnpm/pnpm#7164
zkochan pushed a commit to pnpm/npm-lifecycle that referenced this issue Oct 15, 2023
When a child process sends the INT signal, pnpm should not assume child failed to terminate

Closes pnpm/pnpm#7164

Co-authored-by: Yanick Rochon <yanick.rochon@dynamicly.com>
@yanickrochon
Copy link
Author

According to the reverted changes, this issue was not resolved.

@zkochan
Copy link
Member

zkochan commented Oct 16, 2023

What reverted changes? I have not published your changes yet because the tests are failing on Windows.

@yanickrochon
Copy link
Author

yanickrochon commented Oct 17, 2023

@zkochan ah! my bad, I received this notification on my phone :

image

I don't like checking source codes on a small device, so I assumed the PR had been reverted.

Is it possible to have a Windows CI environment to catch these errors before merged PRs?

@zkochan
Copy link
Member

zkochan commented Oct 17, 2023

CI was not configured on that repository. I have configured it and in the future it won't happen again.

@Stanzilla
Copy link

should this issue be re-opened then?

@Stanzilla
Copy link

@zkochan

@hax
Copy link

hax commented Apr 24, 2024

We met similar issue in pnpm 9.0.2 . Please reopen the issue.

The scripts are like:

{
  "scripts": {
    "dev": "pnpm watch",
    "watch": "node watch1.js & node watch2.js"
  }
}

watch1 and watch2 are processes which need run in background. Execute pnpm watch directly is ok, but pnpm dev will report ELIFECYCLE errors when Ctrl-C. Change pnpm to npm works.

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

Successfully merging a pull request may close this issue.

4 participants