fix(core): prevent cmd popups from isolation (#26730)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior Isolation uses `fork` which can cause popups on windows ## Expected Behavior Isolation uses `spawn` which doesn't cause popups when used with windowsHide. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
f5c8eda6e1
commit
66140faeec
@ -1,5 +1,6 @@
|
|||||||
import { ChildProcess, Serializable, fork } from 'child_process';
|
import { ChildProcess, spawn } from 'child_process';
|
||||||
import path = require('path');
|
import path = require('path');
|
||||||
|
import { Socket, connect } from 'net';
|
||||||
|
|
||||||
import { PluginConfiguration } from '../../../config/nx-json';
|
import { PluginConfiguration } from '../../../config/nx-json';
|
||||||
|
|
||||||
@ -9,13 +10,13 @@ import { PluginConfiguration } from '../../../config/nx-json';
|
|||||||
import { LoadedNxPlugin, nxPluginCache } from '../internal-api';
|
import { LoadedNxPlugin, nxPluginCache } from '../internal-api';
|
||||||
import { getPluginOsSocketPath } from '../../../daemon/socket-utils';
|
import { getPluginOsSocketPath } from '../../../daemon/socket-utils';
|
||||||
import { consumeMessagesFromSocket } from '../../../utils/consume-messages-from-socket';
|
import { consumeMessagesFromSocket } from '../../../utils/consume-messages-from-socket';
|
||||||
|
import { signalToCode } from '../../../utils/exit-codes';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
consumeMessage,
|
consumeMessage,
|
||||||
isPluginWorkerResult,
|
isPluginWorkerResult,
|
||||||
sendMessageOverSocket,
|
sendMessageOverSocket,
|
||||||
} from './messaging';
|
} from './messaging';
|
||||||
import { Socket, connect } from 'net';
|
|
||||||
|
|
||||||
const cleanupFunctions = new Set<() => void>();
|
const cleanupFunctions = new Set<() => void>();
|
||||||
|
|
||||||
@ -248,7 +249,6 @@ function createWorkerExitHandler(
|
|||||||
|
|
||||||
let cleanedUp = false;
|
let cleanedUp = false;
|
||||||
const exitHandler = () => {
|
const exitHandler = () => {
|
||||||
if (cleanedUp) return;
|
|
||||||
for (const fn of cleanupFunctions) {
|
for (const fn of cleanupFunctions) {
|
||||||
fn();
|
fn();
|
||||||
}
|
}
|
||||||
@ -256,7 +256,10 @@ const exitHandler = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
process.on('exit', exitHandler);
|
process.on('exit', exitHandler);
|
||||||
process.on('SIGINT', exitHandler);
|
process.on('SIGINT', () => {
|
||||||
|
exitHandler();
|
||||||
|
process.exit(signalToCode('SIGINT'));
|
||||||
|
});
|
||||||
process.on('SIGTERM', exitHandler);
|
process.on('SIGTERM', exitHandler);
|
||||||
|
|
||||||
function registerPendingPromise(
|
function registerPendingPromise(
|
||||||
@ -314,17 +317,21 @@ async function startPluginWorker() {
|
|||||||
[process.pid, global.nxPluginWorkerCount++].join('-')
|
[process.pid, global.nxPluginWorkerCount++].join('-')
|
||||||
);
|
);
|
||||||
|
|
||||||
const worker = fork(workerPath, [ipcPath], {
|
const worker = spawn(
|
||||||
stdio: process.stdout.isTTY ? 'inherit' : 'ignore',
|
process.execPath,
|
||||||
env,
|
[
|
||||||
execArgv: [
|
...(isWorkerTypescript ? ['--require', 'ts-node/register'] : []),
|
||||||
...process.execArgv,
|
workerPath,
|
||||||
// If the worker is typescript, we need to register ts-node
|
ipcPath,
|
||||||
...(isWorkerTypescript ? ['-r', 'ts-node/register'] : []),
|
|
||||||
],
|
],
|
||||||
detached: true,
|
{
|
||||||
});
|
stdio: process.stdout.isTTY ? 'inherit' : 'ignore',
|
||||||
worker.disconnect();
|
env,
|
||||||
|
detached: true,
|
||||||
|
shell: false,
|
||||||
|
windowsHide: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
worker.unref();
|
worker.unref();
|
||||||
|
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user