Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/gradle/src/utils/exec-gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ export function execGradleAsync(

cp.on('exit', (code, signal) => {
if (code === null) code = signalToCode(signal);
// Forcibly destroy streams to prevent Gradle daemon pipe hang.
// When shell: true is used, the Gradle daemon inherits the shell's
// stdout/stderr pipes and holds them open after the task completes.
// This prevents the shell wrapper from exiting, which in turn
// prevents the 'exit' event from firing on the ChildProcess.
// By this point all output has already been buffered, so destroying
// the streams is safe and releases the pipe FDs from Node's
// perspective.
// See: nodejs/node#5637, gradle/gradle#3987
cp.stdout?.destroy();
cp.stderr?.destroy();
if (code === 0) {
res(stdout);
} else {
Expand Down