Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(mcp-host): signal the entrypoint test only after the SIGTERM handler exists
Alfredo Lopez1f6b4fd490f0
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 6d0e027ac..ea6dc25e1 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.586",+ "version": "0.1.587","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.586",+ "version": "0.1.587","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex b89b95db0..f9cc888a8 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.586",+ "version": "0.1.587","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/__tests__/fixtures/dbWorkerControl.cjs b/mcp-host/src/__tests__/fixtures/dbWorkerControl.cjsindex 07d7de3ac..faf7583c8 100644--- a/mcp-host/src/__tests__/fixtures/dbWorkerControl.cjs+++ b/mcp-host/src/__tests__/fixtures/dbWorkerControl.cjs@@ -9,8 +9,19 @@// an unexpected worker exit while the Host is serving.//// Every other message reaches the real worker unchanged.+//+// In every mode the preload prints PRELOAD_SIGTERM_HANDLER_READY once main.ts+// has installed its SIGTERM handler, so a test never signals before it.const workerThreads = require('node:worker_threads')+const sigtermReady = setInterval(() => {+ if (process.listenerCount('SIGTERM') > 0) {+ process.stdout.write('PRELOAD_SIGTERM_HANDLER_READY\n')+ clearInterval(sigtermReady)+ }+}, 5)+sigtermReady.unref()+const RealWorker = workerThreads.Workerconst mode = process.env.DB_WORKER_CONTROLif (mode !== 'withhold-shutdown' && mode !== 'terminate-on-sigusr2') {diff --git a/mcp-host/src/__tests__/main.persistFailureExit.test.ts b/mcp-host/src/__tests__/main.persistFailureExit.test.tsindex cc500ce71..49f411874 100644--- a/mcp-host/src/__tests__/main.persistFailureExit.test.ts+++ b/mcp-host/src/__tests__/main.persistFailureExit.test.ts@@ -26,7 +26,8 @@ interface ChildRun {function runHost(control: 'withhold-shutdown' | 'terminate-on-sigusr2',- signal: 'SIGTERM' | 'SIGUSR2'+ signal: 'SIGTERM' | 'SIGUSR2',+ readyMarker: string): Promise<ChildRun> {const home = fs.mkdtempSync(path.join(tmpRoot, 'host-'))const child = spawn(process.execPath, ['--require', PRELOAD, mainScript], {@@ -55,7 +56,7 @@ function runHost(if (!signalled &&output.includes('[ConversationStore] opened') &&- output.includes('MCP Host running in dev mode')+ output.includes(readyMarker)) {signalled = truechild.kill(signal)@@ -86,11 +87,14 @@ afterAll(() => {describe('main.ts persist-failure exit wiring (real entrypoint)', () => {it('exits 1 when the store cannot close during a graceful shutdown', async () => {- const run = await runHost('withhold-shutdown', 'SIGTERM')+ // Signalled only once main.ts has installed its SIGTERM handler; before+ // that, the default action would kill the child.+ const run = await runHost('withhold-shutdown', 'SIGTERM', 'PRELOAD_SIGTERM_HANDLER_READY')// Witnesses: the real store opened, the preload engaged, and the// progress bound fired inside the shutdown window.expect(run.output, run.output).toContain('[ConversationStore] opened')+ expect(run.output, run.output).toContain('PRELOAD_SIGTERM_HANDLER_READY')expect(run.output, run.output).toContain('PRELOAD_WITHHELD_SHUTDOWN')expect(run.output, run.output).toContain('db worker made no progress')expect(run.output, run.output).toContain(@@ -102,7 +106,8 @@ describe('main.ts persist-failure exit wiring (real entrypoint)', () => {}, 30_000)it('exits 1 when the DB worker exits while the Host is serving', async () => {- const run = await runHost('terminate-on-sigusr2', 'SIGUSR2')+ // The preload installs the SIGUSR2 handler before main.ts runs.+ const run = await runHost('terminate-on-sigusr2', 'SIGUSR2', 'MCP Host running in dev mode')expect(run.output, run.output).toContain('[ConversationStore] opened')expect(run.output, run.output).toContain('PRELOAD_TERMINATING_DB_WORKER')