Skip to content

ref(clack-utils): Use child_process spawn instead of exec when installing package - #859

Merged
Lms24 merged 6 commits into
masterfrom
lms/ref-cp-spawn
Mar 18, 2025
Merged

Lms24 merged 6 commits into
masterfrom
lms/ref-cp-spawn

Conversation

@Lms24

@Lms24 Lms24 commented Mar 17, 2025 •

Copy link
Copy Markdown
Member

This PR refactors our installPackage helper to use spawn instead of exec. While using spawn is a bit more complicated, it gives us finer control over the the child process lifecycle as well as runtime. This is primarily made because I want to attempt fixing #851.

Additionally, we now send an error to Sentry when this happens to keep track how often this would occur. Previously, such errors weren't captured by Sentry since we try/caught the promise rejection.

I'll open another follow-up PR to split up the clack-utils file. This thing has become huge and no longer is easy to maintain.

@codecov

codecov Bot commented Mar 17, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 68.18182% with 7 lines in your changes missing coverage. Please review.

Project coverage is 51.55%. Comparing base (40f62ce) to head (9bdfe7a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/utils/clack-utils.ts 65.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #859   +/-   ##
=======================================
  Coverage   51.54%   51.55%           
=======================================
  Files          53       53           
  Lines        3618     3629   +11     
  Branches      854      855    +1     
=======================================
+ Hits         1865     1871    +6     
- Misses       1623     1628    +5     
  Partials      130      130           
Flag Coverage Δ
e2e-tests 80.85% <ø> (ø)
unit-tests 50.37% <68.18%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Lms24 Lms24 self-assigned this Mar 17, 2025
@Lms24
Lms24 requested review from andreiborza and lforst March 17, 2025 10:03
@Lms24
Lms24 force-pushed the lms/ref-cp-spawn branch from e614d19 to 563457b Compare March 17, 2025 10:09
@Lms24 Lms24 changed the title ref(clack-utils): Use child_process spawn instead of exec when to install package ref(clack-utils): Use child_process spawn instead of exec when installing package Mar 17, 2025
Comment thread src/utils/clack-utils.ts Outdated
Comment on lines +410 to +417
JSON.stringify(
{
stdout,
stderr,
},
null,
2,
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno if it's worth doing this change. The output is an object with two gargantuan unreadable strings anyhow 🤷‍♂️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough :) reverted for now

Comment thread src/utils/clack-utils.ts Outdated
const installProcess = childProcess.spawn(
pkgManager.name,
installArgs,
{ shell: true },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add stdio: ['pipe', 'ignore', 'pipe'] it fixes #851 but we cannot then listen on stdout further down the line.

Seems okay to me to do, wdyt?

@Lms24
Lms24 merged commit c2c62dd into master Mar 18, 2025
@Lms24
Lms24 deleted the lms/ref-cp-spawn branch March 18, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants