Skip to content

Cannot run a mock server with a URL spec on macOS or Linux when using Node.js 24 #2723

@natesilva

Description

@natesilva

Hello! I get an error when I try to mock https://petstore3.swagger.io/api/v3/openapi.json and I am running on macOS or Linux (works on Windows).

All platforms are using the latest Node.js, version 24.11.1.

❯ prism mock https://petstore3.swagger.io/api/v3/openapi.json
[9:21:39 AM] › [CLI] …  awaiting  Starting Prism…
[9:21:39 AM] › [CLI] ✖  fatal     Error downloading https://petstore3.swagger.io/api/v3/openapi.json 
RequestInit: Expected signal ("AbortSignal {
  eventEmitter: EventEmitter {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    Symbol(shapeMode): false,
    Symbol(kCapture): false
  },
  onabort: null,
  aborted: false,
  reason: undefined
}") to be an instance of AbortSignal.
prism mock <document>

Start a mock server with the given document file

Positionals:
  document  Path to a document file. Can be both a file or a fetchable resource on the web.                              [string] [required]

Options:
      --version                           Show version number                                                                      [boolean]
      --help                              Show help                                                                                [boolean]
  -p, --port                              Port that Prism will run on.                                   [number] [required] [default: 4010]
  -h, --host                              Host that Prism will listen to.                         [string] [required] [default: "127.0.0.1"]
      --cors                              Enables CORS headers.                                                    [boolean] [default: true]
  -m, --multiprocess                      Forks the http server from the CLI for faster log processing.           [boolean] [default: false]
      --errors                            Specifies whether request/response violations marked as errors will produce an error response
                                                                                                       [boolean] [required] [default: false]
  -v, --verboseLevel                      Turns on verbose logging.
                                        [required] [choices: "trace", "debug", "info", "warn", "error", "fatal", "silent"] [default: "info"]
  -d, --dynamic                           Dynamically generate examples.                                          [boolean] [default: false]
      --json-schema-faker-fillProperties  Generate additional properties when using dynamic generation.                            [boolean]
      --ignoreExamples                    Tell Prism to treat the spec as though it has no examples. When in static mode,
                                          returns an example that has not been generated using json-schema-faker, but was
                                          created by Prism. When in dynamic mode, this flag is ignored, since in dynamic mode,
                                          examples are not consulted and json-schema-faker is used to generate a response based
                                          on the schema defined in the spec                                       [boolean] [default: false]
      --seed                              Provide a seed so that Prism generates dynamic examples deterministically
                                                                                                         [string] [required] [default: null]

{
  stack: 'ResolverError: Error downloading https://petstore3.swagger.io/api/v3/openapi.json \n' +
    'RequestInit: Expected signal ("AbortSignal {\n' +
    '  eventEmitter: EventEmitter {\n' +
    '    _events: [Object: null prototype] {},\n' +
    '    _eventsCount: 0,\n' +
    '    _maxListeners: undefined,\n' +
    '    Symbol(shapeMode): false,\n' +
    '    Symbol(kCapture): false\n' +
    '  },\n' +
    '  onabort: null,\n' +
    '  aborted: false,\n' +
    '  reason: undefined\n' +
    '}") to be an instance of AbortSignal.\n' +
    '    at download (/Users/nate/.volta/tools/image/packages/@stoplight/prism-cli/lib/node_modules/@stoplight/prism-cli/node_modules/@stoplight/json-schema-ref-parser/lib/resolvers/http.js:175:11)\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:105:5)',
  code: 'ERESOLVER',
  message: 'Error downloading https://petstore3.swagger.io/api/v3/openapi.json \n' +
    'RequestInit: Expected signal ("AbortSignal {\n' +
    '  eventEmitter: EventEmitter {\n' +
    '    _events: [Object: null prototype] {},\n' +
    '    _eventsCount: 0,\n' +
    '    _maxListeners: undefined,\n' +
    '    Symbol(shapeMode): false,\n' +
    '    Symbol(kCapture): false\n' +
    '  },\n' +
    '  onabort: null,\n' +
    '  aborted: false,\n' +
    '  reason: undefined\n' +
    '}") to be an instance of AbortSignal.',
  source: 'https://petstore3.swagger.io/api/v3/openapi.json',
  path: null,
  toJSON: [Function: toJSON],
  name: 'ResolverError',
  toString: [Function: toString]
}

Context

  • This happens on macOS and Linux. Works on Windows.
  • The spec URL is accessible. I am able to retrieve it using curl.
  • The same thing happens with other OpenAPI spec URLs, not just the one I tested.

Current Behavior

Unable to run the mock server when the spec is on a URL.

Expected Behavior

I should be able to point Prism to any valid OpenAPI URL and get a mock server.

Possible Workaround/Solution

  • Workaround 1: Download the spec to a local file.
    • While this works, we want to mock based on a server-hosted spec so devs don’t have to pre-download and manage multiple spec files.
  • Workaround 2: Use Node.js 22 or earlier.
    • We use the LTS version of Node.js, which is currently Node.js 24, so this is not always viable.

Steps to Reproduce

Mac or Linux

  1. prism mock https://petstore3.swagger.io/api/v3/openapi.json

Linux (clean setup via Docker)

  1. docker run --rm -it node:24 /bin/bash
  2. npm i -g @stoplight/prism-cli
  3. prism mock https://petstore3.swagger.io/api/v3/openapi.json

Environment

  • Version used: Prism 5.14.2
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Node.js 24.11.0
  • Operating System and version (desktop or mobile): macOS Tahoe 26.1, Ubuntu 24.04.3 LTS

AI-based troubleshooting

Both Claude and ChatGPT suggest the problem is in @stoplight/json-schema-ref-parser:

Node.js made breaking changes to the AbortSignal implementation in recent versions. The @stoplight/json-schema-ref-parser library (used internally by Prism) is passing an AbortSignal that was created in one realm/context, but Node.js's fetch implementation expects an AbortSignal from its own realm. This is causing an instanceof check to fail.

This issue affects Mac and Linux because they likely use Node.js's native fetch implementation, while Windows might be using a different fetch polyfill or older Node.js behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions