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

Lerna utils detectProjects() function prevents natural process exit #3961

Open
mstrater opened this issue Feb 24, 2024 · 0 comments
Open

Lerna utils detectProjects() function prevents natural process exit #3961

mstrater opened this issue Feb 24, 2024 · 0 comments

Comments

@mstrater
Copy link

Current Behavior

If you run a script that uses Lerna's detectProjects() function in the root of the monorepo, it somehow leaves a socket open, preventing the script from naturally exiting once it's finished running.

Expected Behavior

I expect detectProjects() to run as normal and then allow the script to exit naturally.

Steps to Reproduce

Add this script to a lerna monorepo:

const { detectProjects } = require('lerna/utils');
// const wtf = require('wtfnode');

const test = async () => {
  const { projectGraph, projectFileMap } = await detectProjects();
  // wtf.dump();
};
test();

Run this script and the script will never exit. The commented out wtfnode parts are useful for seeing that a socket remains open once the script finishes running. wtfnode ouputs:

stratem@ADSKJK7J3257WP getting-started-example % node test.js            
[WTF Node?] open handles:
- File descriptors: (note: stdio always exists)
  - fd 1 (tty) (stdio)
  - fd 2 (tty) (stdio)
  - fd 0 (tty)
- Sockets:
  - fd 21

I was unable to reproduce this issue on https://github.com/lerna/repro, but I was able to reproduce using the "getting started" sample. Here's a PR with the changes: lerna/getting-started-example#35
Just clone it, npm i, and then run node test.js.

Failure Logs / Configuration

The output from wtfnode is above.

lerna.json

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "version": "0.0.0"
}

Environment

stratem@ADSKJK7J3257WP getting-started-example % npx lerna info
lerna notice cli v7.1.5

 Environment info:

  System:
    OS: macOS 13.6.4
    CPU: (12) arm64 Apple M2 Pro
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
  Utilities:
    Git: 2.42.0 - /opt/homebrew/bin/git
  npmPackages:
    lerna: ^7.1.5 => 7.1.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant