Skip to content

Process should not exit when pressing ctrl + c under node --run #58662

Closed as not planned
@zanminkian

Description

@zanminkian

Version

24.1.0

Platform

Linux colima 6.8.0-50-generic #51-Ubuntu SMP PREEMPT_DYNAMIC Sat Nov  9 18:03:35 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Reproduce steps:

  1. create package.json: {"scripts":{"x":"node x.js"}}
  2. create x.js:
setTimeout(() => {
  process.exit(0);
}, 10_000);

process.addListener('SIGINT', () => {
  console.log('SIGINT');
});

process.addListener('SIGTERM', () => {
  console.log('SIGTERM');
});
  1. run node --run x
  2. press ctrl+c to kill it.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

It should not be killed. Just like the behavior of running npm run x.

What do you see instead?

The process is killed.

Additional information

This behavior seems unsafe for backend app using Node.js, because backend app started by node --run will do cleaning once it receives SIGINT or SIGTERM from docker container. Docker container may stop immediately because node --run has already exited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions