Skip to content

Commit

Permalink
fix(core): always use host node for spawning the daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Mar 15, 2023
1 parent a4236f8 commit 5319c43
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"@types/semver": "^7.3.8",
"@types/tar-stream": "^2.2.2",
"@types/tmp": "^0.2.0",
"@types/which": "^2.0.2",
"@types/yargs": "^17.0.10",
"@types/yarnpkg__lockfile": "^1.1.5",
"@typescript-eslint/eslint-plugin": "5.38.1",
Expand Down Expand Up @@ -314,7 +315,8 @@
"tailwindcss": "3.2.4",
"tslib": "^2.3.0",
"vitest": "^0.25.8",
"weak-napi": "^2.0.2"
"weak-napi": "^2.0.2",
"which": "^3.0.0"
},
"resolutions": {
"**/xmlhttprequest-ssl": "~1.6.2",
Expand All @@ -334,4 +336,3 @@
]
}
}

1 change: 1 addition & 0 deletions packages/nx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"tsconfig-paths": "^4.1.2",
"tslib": "^2.3.0",
"v8-compile-cache": "2.3.0",
"which": "^3.0.0",
"yargs": "^17.6.2",
"yargs-parser": "21.1.1"
},
Expand Down
6 changes: 5 additions & 1 deletion packages/nx/src/daemon/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ensureDirSync, ensureFileSync } from 'fs-extra';
import { connect } from 'net';
import { join } from 'path';
import { performance } from 'perf_hooks';
import * as which from 'which';
import { output } from '../../utils/output';
import { FULL_OS_SOCKET_PATH, killSocketOrPath } from '../socket-utils';
import {
Expand Down Expand Up @@ -315,8 +316,11 @@ export class DaemonClient {

const out = openSync(DAEMON_OUTPUT_LOG_FILE, 'a');
const err = openSync(DAEMON_OUTPUT_LOG_FILE, 'a');
// Find the node path based on the path.
// This allows us to use the node version based on the host os, rather than other host processes
const nodeExecutable = await which("node")
const backgroundProcess = spawn(
process.execPath,
nodeExecutable,
[join(__dirname, '../server/start.js')],
{
cwd: workspaceRoot,
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/daemon/server/shutdown-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export async function handleServerProcessTermination({
}: HandleServerProcessTerminationParams) {
try {
server.close();
deleteDaemonJsonProcessCache();
if (sourceWatcherSubscription) {
await sourceWatcherSubscription.unsubscribe();
serverLogger.watcherLog(
Expand All @@ -63,6 +62,7 @@ export async function handleServerProcessTermination({
);
}
serverLogger.log(`Server stopped because: "${reason}"`);
deleteDaemonJsonProcessCache();
} finally {
process.exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/daemon/tmp-dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function isDaemonDisabled() {

function socketDirName() {
const hasher = createHash('sha256');
hasher.update(workspaceRoot);
hasher.update(workspaceRoot.toLowerCase());
const unique = hasher.digest('hex').substring(0, 20);
return join(tmpdir, unique);
}
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8047,6 +8047,11 @@
anymatch "^3.0.0"
source-map "^0.6.0"

"@types/which@^2.0.2":
version "2.0.2"
resolved "http://localhost:4873/@types%2fwhich/-/which-2.0.2.tgz#54541d02d6b1daee5ec01ac0d1b37cecf37db1ae"
integrity sha512-113D3mDkZDjo+EeUEHCFy0qniNc1ZpecGiAU7WSo7YDoSzolZIQKpYFHrPpjkB2nuyahcKfrmLXeQlh7gqJYdw==

"@types/ws@^8.5.1":
version "8.5.3"
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d"
Expand Down Expand Up @@ -26020,7 +26025,7 @@ which@^2.0.1, which@^2.0.2:

which@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/which/-/which-3.0.0.tgz#a9efd016db59728758a390d23f1687b6e8f59f8e"
resolved "http://localhost:4873/which/-/which-3.0.0.tgz#a9efd016db59728758a390d23f1687b6e8f59f8e"
integrity sha512-nla//68K9NU6yRiwDY/Q8aU6siKlSs64aEC7+IV56QoAuyQT2ovsJcgGYGyqMOmI/CGN1BOR6mM5EN0FBO+zyQ==
dependencies:
isexe "^2.0.0"
Expand Down

0 comments on commit 5319c43

Please sign in to comment.