nx 19.8.12 → 19.8.13

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.8.12",
3
+ "version": "19.8.13",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -67,7 +67,7 @@
67
67
  "yargs-parser": "21.1.1",
68
68
  "node-machine-id": "1.1.12",
69
69
  "ora": "5.3.0",
70
- "@nrwl/tao": "19.8.12"
70
+ "@nrwl/tao": "19.8.13"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "@swc-node/register": "^1.8.0",
@@ -82,16 +82,16 @@
82
82
  }
83
83
  },
84
84
  "optionalDependencies": {
85
- "@nx/nx-darwin-x64": "19.8.12",
86
- "@nx/nx-darwin-arm64": "19.8.12",
87
- "@nx/nx-linux-x64-gnu": "19.8.12",
88
- "@nx/nx-linux-x64-musl": "19.8.12",
89
- "@nx/nx-win32-x64-msvc": "19.8.12",
90
- "@nx/nx-linux-arm64-gnu": "19.8.12",
91
- "@nx/nx-linux-arm64-musl": "19.8.12",
92
- "@nx/nx-linux-arm-gnueabihf": "19.8.12",
93
- "@nx/nx-win32-arm64-msvc": "19.8.12",
94
- "@nx/nx-freebsd-x64": "19.8.12"
85
+ "@nx/nx-darwin-x64": "19.8.13",
86
+ "@nx/nx-darwin-arm64": "19.8.13",
87
+ "@nx/nx-linux-x64-gnu": "19.8.13",
88
+ "@nx/nx-linux-x64-musl": "19.8.13",
89
+ "@nx/nx-win32-x64-msvc": "19.8.13",
90
+ "@nx/nx-linux-arm64-gnu": "19.8.13",
91
+ "@nx/nx-linux-arm64-musl": "19.8.13",
92
+ "@nx/nx-linux-arm-gnueabihf": "19.8.13",
93
+ "@nx/nx-win32-arm64-msvc": "19.8.13",
94
+ "@nx/nx-freebsd-x64": "19.8.13"
95
95
  },
96
96
  "nx-migrations": {
97
97
  "migrations": "./migrations.json",
@@ -408,6 +408,9 @@ class DaemonClient {
408
408
  }
409
409
  }
410
410
  async startInBackground() {
411
+ if (global.NX_PLUGIN_WORKER) {
412
+ throw new Error('Fatal Error: Something unexpected has occurred. Plugin Workers should not start a new daemon process. Please report this issue.');
413
+ }
411
414
  (0, node_fs_1.mkdirSync)(tmp_dir_1.DAEMON_DIR_FOR_CURRENT_WORKSPACE, { recursive: true });
412
415
  if (!(0, node_fs_1.existsSync)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE)) {
413
416
  (0, node_fs_1.writeFileSync)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, '');
@@ -353,6 +353,15 @@ async function startServer() {
353
353
  server.listen((0, socket_utils_1.getFullOsSocketPath)(), async () => {
354
354
  try {
355
355
  logger_1.serverLogger.log(`Started listening on: ${(0, socket_utils_1.getFullOsSocketPath)()}`);
356
+ setInterval(() => {
357
+ if ((0, cache_1.getDaemonProcessIdSync)() !== process.pid) {
358
+ return (0, shutdown_utils_1.handleServerProcessTermination)({
359
+ server,
360
+ reason: 'this process is no longer the current daemon (native)',
361
+ sockets: exports.openSockets,
362
+ });
363
+ }
364
+ }).unref();
356
365
  // this triggers the storage of the lock file hash
357
366
  daemonIsOutdated();
358
367
  if (!(0, shutdown_utils_1.getWatcherInstance)()) {
Binary file
@@ -10,9 +10,19 @@ if (process.env.NX_PERF_LOGGING === 'true') {
10
10
  require('../../../utils/perf-logging');
11
11
  }
12
12
  global.NX_GRAPH_CREATION = true;
13
+ global.NX_PLUGIN_WORKER = true;
14
+ let connected = false;
13
15
  let plugin;
14
16
  const socketPath = process.argv[2];
15
17
  const server = (0, net_1.createServer)((socket) => {
18
+ connected = true;
19
+ // This handles cases where the host process was killed
20
+ // after the worker connected but before the worker was
21
+ // instructed to load the plugin.
22
+ const loadTimeout = setTimeout(() => {
23
+ console.error(`Plugin Worker exited because no plugin was loaded within 10 seconds of starting up.`);
24
+ process.exit(1);
25
+ }, 10000).unref();
16
26
  socket.on('data', (0, consume_messages_from_socket_1.consumeMessagesFromSocket)((raw) => {
17
27
  const message = JSON.parse(raw.toString());
18
28
  if (!(0, messaging_1.isPluginWorkerMessage)(message)) {
@@ -20,6 +30,8 @@ const server = (0, net_1.createServer)((socket) => {
20
30
  }
21
31
  return (0, messaging_1.consumeMessage)(socket, message, {
22
32
  load: async ({ plugin: pluginConfiguration, root }) => {
33
+ if (loadTimeout)
34
+ clearTimeout(loadTimeout);
23
35
  process.chdir(root);
24
36
  try {
25
37
  const [promise] = (0, loader_1.loadNxPlugin)(pluginConfiguration, root);
@@ -131,6 +143,8 @@ const server = (0, net_1.createServer)((socket) => {
131
143
  // since the worker is spawned per host process. As such,
132
144
  // we can safely close the worker when the host disconnects.
133
145
  socket.on('end', () => {
146
+ // Destroys the socket once it's fully closed.
147
+ socket.destroySoon();
134
148
  // Stops accepting new connections, but existing connections are
135
149
  // not closed immediately.
136
150
  server.close(() => {
@@ -140,11 +154,15 @@ const server = (0, net_1.createServer)((socket) => {
140
154
  catch (e) { }
141
155
  process.exit(0);
142
156
  });
143
- // Destroys the socket once it's fully closed.
144
- socket.destroySoon();
145
157
  });
146
158
  });
147
159
  server.listen(socketPath);
160
+ setTimeout(() => {
161
+ if (!connected) {
162
+ console.error('The plugin worker is exiting as it was not connected to within 5 seconds.');
163
+ process.exit(1);
164
+ }
165
+ }, 5000).unref();
148
166
  const exitHandler = (exitCode) => () => {
149
167
  server.close();
150
168
  try {