Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Drop the fs-patching publication witness from the detached-spawn test (#5554)
Nick Gomez5e54b09ebfbd
diff --git a/packages/cli/tests/integration/_helpers/state-publication-preload.cjs b/packages/cli/tests/integration/_helpers/state-publication-preload.cjsdeleted file mode 100644index b0c80999c..000000000--- a/packages/cli/tests/integration/_helpers/state-publication-preload.cjs+++ /dev/null@@ -1,27 +0,0 @@-const fs = require('node:fs');-const { syncBuiltinESMExports } = require('node:module');--const stateFile = process.env.OK_TEST_STATE_FILE;-const witnessFile = process.env.OK_TEST_STATE_WITNESS;-if (!stateFile || !witnessFile) throw new Error('State publication observation paths are required');--const originalOpen = fs.openSync;-const originalWrite = fs.writeFileSync;-const originalRead = fs.readFileSync;-const matches = (file) => file === stateFile || file === `${stateFile}.pending`;--fs.writeFileSync = (file, data, options) => {- if (!matches(file) || typeof data !== 'string') return originalWrite(file, data, options);- const encoding = typeof options === 'string' ? options : (options?.encoding ?? 'utf8');- return originalWrite(file, Buffer.from(data, encoding), options);-};--fs.openSync = (...args) => {- const fd = Reflect.apply(originalOpen, fs, args);- if (!matches(args[0]) || args[1] !== 'w') return fd;- const contents = fs.existsSync(stateFile) ? originalRead(stateFile, 'utf8') : null;- originalWrite(witnessFile, JSON.stringify(contents));- return fd;-};--syncBuiltinESMExports();diff --git a/packages/cli/tests/integration/detached-spawn-lifetime.test.ts b/packages/cli/tests/integration/detached-spawn-lifetime.test.tsindex 617e14314..e158199c0 100644--- a/packages/cli/tests/integration/detached-spawn-lifetime.test.ts+++ b/packages/cli/tests/integration/detached-spawn-lifetime.test.ts@@ -4,7 +4,6 @@ import { request as httpRequest } from 'node:http';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';-import { fileURLToPath } from 'node:url';import { afterEach, beforeEach, describe, expect, it } from 'vitest';function isProcessAlive(pid: number): boolean {@@ -58,10 +57,6 @@ describe('detached spawn lifetime (A3 / D-003)', () => {it('grandchild survives parent exit AND keeps serving HTTP for ≥5s', async () => {const grandchildScript = join(testDir, 'grandchild.mjs');const stateFile = join(testDir, 'grandchild.state.json');- const witnessFile = join(testDir, 'grandchild.publication.json');- const publicationPreload = fileURLToPath(- new URL('./_helpers/state-publication-preload.cjs', import.meta.url),- );const mcpSurrogateScript = join(testDir, 'mcp-surrogate.mjs');writeFileSync(@@ -94,14 +89,9 @@ process.exit(0);mcpSurrogateScript,`import { spawn } from 'node:child_process';-const child = spawn('node', ['--require', ${JSON.stringify(publicationPreload)}, ${JSON.stringify(grandchildScript)}], {+const child = spawn('node', [${JSON.stringify(grandchildScript)}], {detached: true,stdio: ['ignore', 'ignore', 'ignore'],- env: {- ...process.env,- OK_TEST_STATE_FILE: ${JSON.stringify(stateFile)},- OK_TEST_STATE_WITNESS: ${JSON.stringify(witnessFile)},- },});child.unref();setTimeout(() => process.exit(0), 300);@@ -132,9 +122,6 @@ setTimeout(() => process.exit(0), 300);expect(state.pid).toBeGreaterThan(0);expect(state.port).toBeGreaterThan(0);- const observed: unknown = JSON.parse(readFileSync(witnessFile, 'utf-8'));- expect(observed).toBeNull();-if (mcpPid !== undefined) {expect(isProcessAlive(mcpPid)).toBe(false);}