From b8274ce307c9938bf7fea66eb731fc9d51e99fde Mon Sep 17 00:00:00 2001 From: Ignacio Vidal Date: Sun, 14 Jun 2026 10:09:41 +0100 Subject: [PATCH] fix(cli): correct node:cluster import for multiprocess mode Multiprocess mode crashed on startup with "Cannot read properties of undefined (reading 'isPrimary')". The default import of node:cluster compiled to a `.default` access, which is undefined at runtime because the project builds CommonJS without esModuleInterop and node:cluster's API lives on the module object itself. Use an import-equals require and reconcile the @types/node default-export typing with the runtime shape. --- packages/cli/src/util/createServer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/util/createServer.ts b/packages/cli/src/util/createServer.ts index f46532832..55dd852ce 100644 --- a/packages/cli/src/util/createServer.ts +++ b/packages/cli/src/util/createServer.ts @@ -2,7 +2,11 @@ import { createLogger } from '@stoplight/prism-core'; import { IHttpConfig, IHttpRequest } from '@stoplight/prism-http'; import { createServer as createHttpServer } from '@stoplight/prism-http-server'; import * as chalk from 'chalk'; -import cluster from 'node:cluster'; +// `@types/node` models node:cluster's API as the module's default export, but at runtime (CJS, +// without esModuleInterop) the API lives on the module object itself. Import-equals gives the +// correct runtime object; `.default ?? clusterModule` reconciles the typings with runtime. +import clusterModule = require('node:cluster'); +const cluster = (clusterModule as typeof clusterModule & { default?: typeof clusterModule }).default ?? clusterModule; import * as E from 'fp-ts/Either'; import { pipe } from 'fp-ts/function'; import * as pino from 'pino';