nx 20.2.0-canary.20241114-08953af → 20.2.0-canary.20241116-8efad63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
|
@@ -12,7 +12,15 @@ const pluginNames = new Map();
|
|
12
12
|
const PLUGIN_TIMEOUT_HINT_TEXT = 'As a last resort, you can set NX_PLUGIN_NO_TIMEOUTS=true to bypass this timeout.';
|
13
13
|
const MINUTES = 10;
|
14
14
|
const MAX_MESSAGE_WAIT = process.env.NX_PLUGIN_NO_TIMEOUTS === 'true'
|
15
|
-
?
|
15
|
+
? // Registering a timeout prevents the process from exiting
|
16
|
+
// if the call to a plugin happens to be the only thing
|
17
|
+
// keeping the process alive. As such, even if timeouts are disabled
|
18
|
+
// we need to register one. 2147483647 is the max timeout
|
19
|
+
// that Node.js allows, and is equivalent to 24.8 days....
|
20
|
+
// This does mean that the NX_PLUGIN_NO_TIMEOUTS env var
|
21
|
+
// would still timeout after 24.8 days, but that seems
|
22
|
+
// like a reasonable compromise.
|
23
|
+
2147483647
|
16
24
|
: 1000 * 60 * MINUTES; // 10 minutes
|
17
25
|
const nxPluginWorkerCache = (global['nxPluginWorkerCache'] ??= new Map());
|
18
26
|
async function loadRemoteNxPlugin(plugin, root) {
|
@@ -35,11 +43,9 @@ async function loadRemoteNxPlugin(plugin, root) {
|
|
35
43
|
payload: { plugin, root },
|
36
44
|
});
|
37
45
|
// logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
|
38
|
-
const loadTimeout =
|
39
|
-
|
40
|
-
|
41
|
-
}, MAX_MESSAGE_WAIT)
|
42
|
-
: undefined;
|
46
|
+
const loadTimeout = setTimeout(() => {
|
47
|
+
rej(new Error(`Loading "${typeof plugin === 'string' ? plugin : plugin.plugin}" timed out after ${MINUTES} minutes. ${PLUGIN_TIMEOUT_HINT_TEXT}`));
|
48
|
+
}, MAX_MESSAGE_WAIT);
|
43
49
|
socket.on('data', (0, consume_messages_from_socket_1.consumeMessagesFromSocket)(createWorkerHandler(worker, pendingPromises, (val) => {
|
44
50
|
if (loadTimeout)
|
45
51
|
clearTimeout(loadTimeout);
|
@@ -169,11 +175,9 @@ function registerPendingPromise(tx, pending, callback, context) {
|
|
169
175
|
const promise = new Promise((res, rej) => {
|
170
176
|
rejector = rej;
|
171
177
|
resolver = res;
|
172
|
-
timeout =
|
173
|
-
|
174
|
-
|
175
|
-
}, MAX_MESSAGE_WAIT)
|
176
|
-
: undefined;
|
178
|
+
timeout = setTimeout(() => {
|
179
|
+
rej(new Error(`${context.plugin} timed out after ${MINUTES} minutes during ${context.operation}. ${PLUGIN_TIMEOUT_HINT_TEXT}`));
|
180
|
+
}, MAX_MESSAGE_WAIT);
|
177
181
|
callback();
|
178
182
|
}).finally(() => {
|
179
183
|
pending.delete(tx);
|