Skip to content

Commit 38722f2

Browse files
committed
processKeepAlive
1 parent 740068d commit 38722f2

File tree

3 files changed

+42
-32
lines changed

3 files changed

+42
-32
lines changed

packages/cli-v3/src/dev/devSupervisor.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,21 @@ class DevSupervisor implements WorkerRuntime {
101101
// Initialize the task run process pool
102102
const env = await this.#getEnvVars();
103103

104+
const processKeepAlive =
105+
this.options.config.processKeepAlive ?? this.options.config.experimental_processKeepAlive;
106+
104107
const enableProcessReuse =
105-
typeof this.options.config.experimental_processKeepAlive === "boolean"
106-
? this.options.config.experimental_processKeepAlive
107-
: typeof this.options.config.experimental_processKeepAlive === "object"
108-
? this.options.config.experimental_processKeepAlive.enabled
108+
typeof processKeepAlive === "boolean"
109+
? processKeepAlive
110+
: typeof processKeepAlive === "object"
111+
? processKeepAlive.enabled
109112
: false;
110113

111114
const maxPoolSize =
112-
typeof this.options.config.experimental_processKeepAlive === "object"
113-
? this.options.config.experimental_processKeepAlive.devMaxPoolSize ?? 25
114-
: 25;
115+
typeof processKeepAlive === "object" ? processKeepAlive.devMaxPoolSize ?? 25 : 25;
115116

116117
const maxExecutionsPerProcess =
117-
typeof this.options.config.experimental_processKeepAlive === "object"
118-
? this.options.config.experimental_processKeepAlive.maxExecutionsPerProcess ?? 50
119-
: 50;
118+
typeof processKeepAlive === "object" ? processKeepAlive.maxExecutionsPerProcess ?? 50 : 50;
120119

121120
if (enableProcessReuse) {
122121
logger.debug("[DevSupervisor] Enabling process reuse", {

packages/cli-v3/src/entryPoints/managed-index-worker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ if (typeof config.machine === "string") {
147147
});
148148
}
149149

150+
const processKeepAlive = config.processKeepAlive ?? config.experimental_processKeepAlive;
151+
150152
await sendMessageInCatalog(
151153
indexerToWorkerMessages,
152154
"INDEX_COMPLETE",
@@ -163,10 +165,10 @@ await sendMessageInCatalog(
163165
customConditions: buildManifest.customConditions,
164166
initEntryPoint: buildManifest.initEntryPoint,
165167
processKeepAlive:
166-
typeof config.experimental_processKeepAlive === "object"
167-
? config.experimental_processKeepAlive
168-
: typeof config.experimental_processKeepAlive === "boolean"
169-
? { enabled: config.experimental_processKeepAlive }
168+
typeof processKeepAlive === "object"
169+
? processKeepAlive
170+
: typeof processKeepAlive === "boolean"
171+
? { enabled: processKeepAlive }
170172
: undefined,
171173
timings,
172174
},

packages/core/src/v3/config.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ export type CompatibilityFlagFeatures = {
1919
[key in CompatibilityFlag]: boolean;
2020
};
2121

22+
type ProcessKeepAlive =
23+
| boolean
24+
| {
25+
enabled: boolean;
26+
/**
27+
* The maximum number of executions per process. If the process has run more than this number of times, it will be killed.
28+
*
29+
* @default 50
30+
*/
31+
maxExecutionsPerProcess?: number;
32+
33+
/**
34+
* The maximum number of processes to keep alive in dev.
35+
*
36+
* @default 25
37+
*/
38+
devMaxPoolSize?: number;
39+
};
40+
2241
export type TriggerConfig = {
2342
/**
2443
* @default "node"
@@ -245,30 +264,20 @@ export type TriggerConfig = {
245264
env?: Record<string, string>;
246265
};
247266

267+
/**
268+
* This still works but use `processKeepAlive` instead.
269+
*
270+
* @deprecated (use processKeepAlive instead)
271+
*/
272+
experimental_processKeepAlive?: ProcessKeepAlive;
273+
248274
/**
249275
* @default false
250276
* @description Keep the process alive after the task has finished running so the next task doesn't have to wait for the process to start up again.
251277
*
252278
* Note that the process could be killed at any time, and we don't make any guarantees about the process being alive for a certain amount of time
253279
*/
254-
experimental_processKeepAlive?:
255-
| boolean
256-
| {
257-
enabled: boolean;
258-
/**
259-
* The maximum number of executions per process. If the process has run more than this number of times, it will be killed.
260-
*
261-
* @default 50
262-
*/
263-
maxExecutionsPerProcess?: number;
264-
265-
/**
266-
* The maximum number of processes to keep alive in dev.
267-
*
268-
* @default 25
269-
*/
270-
devMaxPoolSize?: number;
271-
};
280+
processKeepAlive?: ProcessKeepAlive;
272281

273282
/**
274283
* @default false

0 commit comments

Comments
 (0)