
























@@ -10,6 +10,17 @@ const bundledRuntimeFragments = (pluginDir) => [
1010`/dist-runtime/extensions/${pluginDir}`,
1111];
1212const bundledRuntimeRootFragments = ["/dist/extensions/", "/dist-runtime/extensions/"];
13+const DEFAULT_PLUGIN_LIST_TIMEOUT_MS = 30_000;
14+const DEFAULT_PLUGIN_LIST_MAX_BUFFER_BYTES = 4 * 1024 * 1024;
15+16+function positiveEnvInt(name, fallback) {
17+const raw = process.env[name];
18+if (raw === undefined || raw === "") {
19+return fallback;
20+}
21+const value = Number.parseInt(raw, 10);
22+return Number.isSafeInteger(value) && value > 0 ? value : fallback;
23+}
13241425function resolveStateDir() {
1526if (process.env.OPENCLAW_STATE_DIR) {
@@ -42,11 +53,29 @@ function resolveOpenClawEntry() {
42534354function readPluginsList() {
4455const entry = resolveOpenClawEntry();
56+const timeoutMs = positiveEnvInt(
57+"OPENCLAW_BUNDLED_PLUGIN_LIST_TIMEOUT_MS",
58+DEFAULT_PLUGIN_LIST_TIMEOUT_MS,
59+);
4560const result = spawnSync(process.execPath, [entry, "plugins", "list", "--json"], {
4661cwd: process.cwd(),
4762encoding: "utf8",
4863env: process.env,
64+maxBuffer: positiveEnvInt(
65+"OPENCLAW_BUNDLED_PLUGIN_LIST_MAX_BUFFER_BYTES",
66+DEFAULT_PLUGIN_LIST_MAX_BUFFER_BYTES,
67+),
68+killSignal: "SIGKILL",
69+timeout: timeoutMs,
4970});
71+if (result.error) {
72+const timedOut = result.error.code === "ETIMEDOUT";
73+throw new Error(
74+timedOut
75+ ? `Timed out listing packaged bundled plugins after ${timeoutMs}ms`
76+ : `Unable to list packaged bundled plugins: ${result.error.message}`,
77+);
78+}
5079if (result.status !== 0) {
5180throw new Error(
5281`Unable to list packaged bundled plugins: ${result.stderr || result.stdout || `exit ${result.status}`}`,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。