nodejs / nodejs/node

`node --run` should find a way to avoid keeping a shell around and properly forward signals

Ouverte
#65,712 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

feature request
Langage dominant
JavaScript
Étoiles
122k
Forks
37.3k
Merge moyen
4 j 2 h
PR mergées (30 j)
283

Description

What is the problem this feature will solve?

Node has gained node --run as a way to directly execute a package.json script, but this has a glaring subtle limitation currently that has bitten me and likely others, and is also recurring in the existing package managers: It doesn't forward signals properly to the subprocess, and the shell in the middle can even end up swallowing those signals and lingering when invoked node --run is invoked as PID 1 in Docker.

What is the feature you are proposing to solve the problem?

It would be much nicer to have a variant that can function identically to just a direct node script.js invocation, but with the arguments and command line in the package.json for DRY reasons. This can be problematic though, as package.json scripts are currently arbitrary shell scripts, and Node.js likely just uses sh to execute them rather then any JS shell-emulator (Pnpm, Yarn), which can limit it's ability to directly exec the final ran command so the shell in the middle doesn't swallow signals.

What alternatives have you considered?

Don't use node --run or the package mangers, just direct node script.js duplicating the start command.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez au point d’entrée node --run et suivez la manière dont les scripts de package.json sont lancés, en prêtant une attention particulière au processus shell et au comportement de PID 1 dans Docker. Reproduisez le cas de gestion des signaux décrit dans l’issue ; le travail est terminé lorsque l’invocation proposée évite de laisser un shell indésirable et transmet correctement les signaux sans perdre le comportement existant des scripts.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
docker, javascript, nodejs, shell
Domaine
cli, operating-systems
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.