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

[DUX-2058] Fix bug in use of child_process #64

Merged
merged 3 commits into from
Mar 18, 2024
Merged

Conversation

friedbrice
Copy link
Contributor

We currently use child_process.exec to capture stdout so that it can be processed as one big string. This works great for short-lived CLI utilities, but when used with a long-lived daemon (such as when used with activateCommand) the stdout from the long-lived process overfills a buffer, causing the process to fail.

This patch changed the activateCommand to use child_process.spawn while still preserving the use of child_process.exec for everything else.

@github-actions github-actions bot added the patch label Mar 18, 2024
@friedbrice friedbrice changed the title [DUX-2027] Fix bug in use of child_process [DUX-2058] Fix bug in use of child_process Mar 18, 2024
export function make<T>(spec: Spec, f: (stdout: string) => T): IAsyncProcess<T> {
export function spawn(spec: Spec): IAsyncProcess<void> {
return make<void>(spec, (cmd, opts, resolve) => {
const proc = child_process.spawn(cmd, [], {...opts, shell: true})
Copy link

@michaelkitson michaelkitson Mar 18, 2024

Choose a reason for hiding this comment

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

Huh, I wouldn't have expected spawn(cmd, [], ...) to work, but I'm glad it does, that seems way easier than parsing it! I assume that is what shell: true is for?

@friedbrice friedbrice merged commit 9bf0188 into main Mar 18, 2024
3 checks passed
@friedbrice friedbrice deleted the daniel/dux-2058 branch March 18, 2024 21:02
Copy link

A PR to release these changes has been created, bumping the version from 3.2.1 to 3.2.2.

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

Successfully merging this pull request may close these issues.

2 participants