Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(ci): unbreak app bundle (Turbopack MDX) and Windows daemonStop test

Generfea2ff927c03
diff --git a/src/app/scripts/bundle.ts b/src/app/scripts/bundle.ts
index 795b28036..3efbc4078 100644
--- a/src/app/scripts/bundle.ts
+++ b/src/app/scripts/bundle.ts
@@ -65,11 +65,31 @@ rmSync(blogContentDir, { recursive: true, force: true });
rmSync(blogPublicDir, { recursive: true, force: true });
mkdirSync(blogContentDir, { recursive: true });
+// Next 16's Turbopack resolves the blog's dynamic `import(`@/content/${slug}.mdx`)`
+// into a context module by globbing src/content/*.mdx at build time. An EMPTY
+// dir yields zero matches, which Turbopack treats as a hard "Module not found"
+// error (webpack only warned). Drop one draft placeholder so the glob resolves.
+// It never surfaces: getAllPosts() skips `draft: true`, and no route links it.
+writeFileSync(
+ join(blogContentDir, "_placeholder.mdx"),
+ `export const metadata = {\n` +
+ ` slug: "_placeholder",\n` +
+ ` title: "Placeholder",\n` +
+ ` date: "2020-01-01",\n` +
+ ` author: "Alook",\n` +
+ ` excerpt: "Build-time placeholder; never listed.",\n` +
+ ` readingTime: "1 min",\n` +
+ ` draft: true,\n` +
+ `};\n\nPlaceholder.\n`,
+);
+
try {
run("npx opennextjs-cloudflare build", webSrc);
} finally {
console.log("[bundle] Restoring blog source files...");
try {
+ // Drop the untracked placeholder, then restore the tracked content/images.
+ rmSync(join(blogContentDir, "_placeholder.mdx"), { force: true });
execSync("git checkout -- src/web/public/blog/ src/web/src/content/", {
cwd: monoRoot,
stdio: "inherit",
diff --git a/src/daemon/src/cli/daemonStop.test.ts b/src/daemon/src/cli/daemonStop.test.ts
index 91de590ee..1b8930f5c 100644
--- a/src/daemon/src/cli/daemonStop.test.ts
+++ b/src/daemon/src/cli/daemonStop.test.ts
@@ -26,6 +26,15 @@ describe("daemonStop — event-loop friendly (no spin loop)", () => {
// Spawn a real child so we can send SIGTERM at it. `node -e` picks the
// ambient node binary — no PATH assumptions.
const child = spawn(process.execPath, ["-e", "setInterval(()=>{}, 1000)"], { stdio: "ignore" });
+
+ // Track the child's actual termination via its own `exit` event. daemonStop
+ // kills by raw pid (process.kill), NOT via this ChildProcess handle, so
+ // `child.killed` stays false and `exitCode`/`signalCode` are only populated
+ // once Node delivers the exit event — which does not happen synchronously
+ // when daemonStop resolves (this is why the old assertion flaked on Windows,
+ // where the event lags behind the OS process actually being gone).
+ const exited = new Promise<void>((resolve) => child.once("exit", () => resolve()));
+
const machineKey = "cmk_test_key";
const daemonsDir = path.join(baseDir, "daemons");
fs.mkdirSync(daemonsDir, { recursive: true });
@@ -42,8 +51,9 @@ describe("daemonStop — event-loop friendly (no spin loop)", () => {
await stopPromise;
expect(fs.existsSync(pidfile)).toBe(false);
- // The child should have received the SIGTERM — Node's own exit signal
- // handling terminates cleanly on SIGTERM.
- expect(child.killed || child.exitCode !== null || child.signalCode !== null).toBe(true);
+ // Wait for the child's exit event to land (daemonStop already SIGKILL-escalates
+ // within its grace window, so this resolves well inside the test timeout).
+ await exited;
+ expect(child.exitCode !== null || child.signalCode !== null).toBe(true);
}, 15_000);
});