mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-26 10:13:27 +08:00
fix: keep Gateway startup alive with V8 contradiction exit mode (#171490)
This commit is contained in:
1 parent
d3c6da5773
commit
7c1b789ca5
2 files changed
+11
-10
No files matched your search
@@ -49,12 +49,13 @@ describe.skipIf(Boolean(process.versions.bun))("worker heap limits", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["--freeze-flags-after-init", "--abort-on-contradictory-flags"])(
|
||||
"keeps the process alive with %s",
|
||||
(flag) => {
|
||||
const [before, after, worker] = measure(["--max-old-space-size=1024", flag]);
|
||||
expect(after).toBe(before);
|
||||
expect(worker).toBe(before);
|
||||
},
|
||||
);
|
||||
it.each([
|
||||
"--freeze-flags-after-init",
|
||||
"--abort-on-contradictory-flags",
|
||||
"--exit-on-contradictory-flags",
|
||||
])("keeps the process alive with %s", (flag) => {
|
||||
const [before, after, worker] = measure(["--max-old-space-size=1024", flag]);
|
||||
expect(after).toBe(before);
|
||||
expect(worker).toBe(before);
|
||||
});
|
||||
});
|
||||
@@ -4,11 +4,11 @@ import { isMainThread } from "node:worker_threads";
|
||||
const startupFlags = `${process.execArgv.join(" ")} ${process.env.NODE_OPTIONS ?? ""}`;
|
||||
const heapFlag = /--max[-_](?:old[-_]space[-_]size(?:[-_]percentage)?|heap[-_]size)(?:=|\s)/u;
|
||||
const immutableFlags =
|
||||
/--(?:freeze[-_]flags[-_]after[-_]init|abort[-_]on[-_]contradictory[-_]flags)(?:=(?:true|1))?(?:\s|$)/u;
|
||||
/--(?:freeze[-_]flags[-_]after[-_]init|(?:abort|exit)[-_]on[-_]contradictory[-_]flags)(?:=(?:true|1))?(?:\s|$)/u;
|
||||
|
||||
if (isMainThread && !process.versions.bun && heapFlag.test(startupFlags)) {
|
||||
if (immutableFlags.test(startupFlags)) {
|
||||
// These V8 modes abort natively on a flag change; JavaScript cannot catch it.
|
||||
// These V8 modes terminate natively on a flag change; JavaScript cannot catch it.
|
||||
process.emitWarning("V8 startup flags prevent enforcing per-worker heap limits.");
|
||||
} else {
|
||||
// Existing isolates retain their limits. Only future isolates read these overrides.
|
||||
|
||||
Reference in new issue
Block a user