From edf5662681c92e5734abbc14886d59eecc4c2444 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 00:08:59 +0000 Subject: [PATCH] test(server): measure child startup during npm journey --- .../src/server/plugins/index.posix.test.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/server/src/server/plugins/index.posix.test.ts b/packages/server/src/server/plugins/index.posix.test.ts index ab77898ead..8ec6faedf3 100644 --- a/packages/server/src/server/plugins/index.posix.test.ts +++ b/packages/server/src/server/plugins/index.posix.test.ts @@ -1,3 +1,5 @@ +import type { ChildProcess } from "node:child_process"; +import { channel } from "node:diagnostics_channel"; import { randomUUID } from "node:crypto"; import { writeSync } from "node:fs"; import { @@ -1613,7 +1615,34 @@ export default function contribute() { ]); }, 120_000); - it("preserves dependencies and metadata, and reloads without npm", async () => { + it("preserves dependencies and metadata, and reloads without npm", async ({ onTestFinished }) => { + const processes = channel("child_process"); + const observe = (event: unknown) => { + const child = (event as { process: ChildProcess }).process; + const began = performance.now(); + child.on("message", (message: unknown) => { + if ( + typeof message === "object" && + message !== null && + "type" in message && + message.type === "ready" + ) { + writeSync( + 2, + `npm journey child: plugin ready; ${Math.round(performance.now() - began)}ms\n`, + ); + } + }); + child.once("close", () => { + const command = child.spawnargs.join(" "); + let kind = "other child"; + if (command.includes("--version")) kind = "version probe"; + else if (/\bnpm(?:\.cmd|\.exe)?(?:[" ]|$)/i.test(command)) kind = "npm command"; + writeSync(2, `npm journey child: ${kind}; ${Math.round(performance.now() - began)}ms\n`); + }); + }; + processes.subscribe(observe); + onTestFinished(() => processes.unsubscribe(observe)); const started = performance.now(); let previous = started; const mark = (phase: string) => {