Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(gates): the pattern that made six verifiers unable to fail

esengine83a3eb08f76b
diff --git a/desktop/scripts/engine-parity.mjs b/desktop/scripts/engine-parity.mjs
index 65fbff9eb..19e7934f2 100644
--- a/desktop/scripts/engine-parity.mjs
+++ b/desktop/scripts/engine-parity.mjs
@@ -186,7 +186,8 @@ app.whenReady().then(async () => {
console.log(`RESULT ${JSON.stringify(report)}`);
console.log(`[parity] max cross-backend diff at probes: ${maxDiff}`);
console.log(`\n[engine-parity] ${ok ? 'PASS' : 'FAIL'}`);
- process.exitCode = ok ? 0 : 1;
try { server.close(); } catch { /* ignore */ }
- app.quit();
+ // app.exit, not process.exitCode + app.quit: Electron quits with status 0
+ // whatever exitCode says, so a FAIL would be reported to the caller as a pass.
+ app.exit(ok ? 0 : 1);
});
diff --git a/desktop/scripts/webgpu-bringup.mjs b/desktop/scripts/webgpu-bringup.mjs
index d9b4b2456..4dc2aa9f2 100644
--- a/desktop/scripts/webgpu-bringup.mjs
+++ b/desktop/scripts/webgpu-bringup.mjs
@@ -136,7 +136,8 @@ app.whenReady().then(async () => {
console.log(`RESULT circle=${JSON.stringify(circle)} checkerRed=${JSON.stringify(checkerRed)} checkerBlue=${JSON.stringify(checkerBlue)} right=${JSON.stringify(right)} maskIn=${JSON.stringify(maskIn)} maskOut=${JSON.stringify(maskOut)} afterReset=${JSON.stringify(afterReset)} scoped=${JSON.stringify(scopedClear)} corner=${JSON.stringify(corner)} framesOk=${framesOk} errors=${errors.length}`);
console.log(`\n[webgpu-bringup] ${ok ? 'PASS' : 'FAIL'}`);
- process.exitCode = ok ? 0 : 1;
try { server.close(); } catch { /* ignore */ }
- app.quit();
+ // app.exit, not process.exitCode + app.quit: Electron quits with status 0
+ // whatever exitCode says, so a FAIL would be reported to the caller as a pass.
+ app.exit(ok ? 0 : 1);
});
diff --git a/package.json b/package.json
index 5d25511c3..10a80ad94 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"emsdk:setup": "node build-tools/toolchain/setup-emsdk.js",
"asset-meta": "node tools/asset-meta.js",
"migrate-asset-refs": "node tools/migrate-asset-refs.js",
- "verify": "pnpm --filter ./sdk exec tsc --noEmit && pnpm --filter @estella/editor exec tsc --noEmit && node tools/api-surface.mjs --check && node tools/check-cycles.mjs && node tools/check-layers.mjs && node tools/check-project-settings.mjs && node tools/check-workflows.mjs && node tools/check-tool-calls.mjs && node tools/check-inspector-door.mjs && node tools/check-dirty-source.mjs && node tools/check-path-sandbox.mjs && node tools/check-key-codes.mjs && node tools/check-comment-style.mjs && node tools/check-cpp-tests.mjs && node tools/check-release-metadata.mjs && node tools/check-golden.mjs && node tools/check-engine-gaps.mjs && node tools/check-minigame-host.mjs && node tools/check-release-gate.mjs && node tools/component-reference.mjs --check",
+ "verify": "pnpm --filter ./sdk exec tsc --noEmit && pnpm --filter @estella/editor exec tsc --noEmit && node tools/api-surface.mjs --check && node tools/check-cycles.mjs && node tools/check-layers.mjs && node tools/check-project-settings.mjs && node tools/check-workflows.mjs && node tools/check-tool-calls.mjs && node tools/check-inspector-door.mjs && node tools/check-dirty-source.mjs && node tools/check-path-sandbox.mjs && node tools/check-key-codes.mjs && node tools/check-comment-style.mjs && node tools/check-cpp-tests.mjs && node tools/check-verifier-exit.mjs && node tools/check-release-metadata.mjs && node tools/check-golden.mjs && node tools/check-engine-gaps.mjs && node tools/check-minigame-host.mjs && node tools/check-release-gate.mjs && node tools/component-reference.mjs --check",
"perf": "node tools/perf-guard.mjs --check",
"scale": "node tools/perf-budget.mjs",
"stress-project": "node tools/stress-project.mjs",
diff --git a/tools/check-verifier-exit.mjs b/tools/check-verifier-exit.mjs
new file mode 100644
index 000000000..fc1ee29e5
--- /dev/null
+++ b/tools/check-verifier-exit.mjs
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file check-verifier-exit.mjs — an Electron verifier reports its verdict.
+ *
+ * `process.exitCode = ok ? 0 : 1` is the right thing in Node and a lie under
+ * Electron: the process leaves with status 0 on quit whatever exitCode says. Six
+ * scripts ended that way, so each printed FAIL and told its caller it had
+ * passed — including the twelve scenes CI runs on every push, which therefore
+ * could not fail a build.
+ *
+ * A verdict nothing can act on is worse than no verdict, so this refuses the
+ * pattern rather than trusting everyone to remember. `app.exit(code)` is the
+ * form that works.
+ */
+import { readdirSync, readFileSync, statSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const ROOTS = [path.join(ROOT, 'desktop', 'scripts'), path.join(ROOT, 'tools')];
+
+function scripts(dir) {
+ const out = [];
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
+ const abs = path.join(dir, entry.name);
+ if (entry.isDirectory()) out.push(...scripts(abs));
+ else if (/\.(mjs|js)$/.test(entry.name) && statSync(abs).isFile()) out.push(abs);
+ }
+ return out;
+}
+
+const problems = [];
+let electronScripts = 0;
+for (const root of ROOTS) {
+ for (const file of scripts(root)) {
+ const src = readFileSync(file, 'utf8');
+ if (!/from\s+['"]electron['"]|require\(['"]electron['"]\)/.test(src)) continue;
+ electronScripts++;
+ // The assignment is the defect; naming the pattern in a comment is how the
+ // next reader learns why it is banned.
+ const line = src.split('\n').findIndex((l) => /process\.exitCode\s*=/.test(l.replace(/\/\/.*$/, '')));
+ if (line >= 0) problems.push(`${path.relative(ROOT, file)}:${line + 1}`);
+ }
+}
+
+if (problems.length) {
+ console.error('check-verifier-exit: an Electron script cannot report a failure that way.\n');
+ for (const p of problems) {
+ console.error(` ${p} sets process.exitCode — Electron quits with status 0 regardless. Use app.exit(code).`);
+ }
+ process.exit(1);
+}
+
+console.log(`check-verifier-exit: ${electronScripts} Electron script(s) report their verdict through app.exit.`);