Skip to content

Stream crashes after first usage: ERR_NOCK_NO_MATCH #4

@ggorlen

Description

@ggorlen

See #3 for context. The commit that implements this, c9bde80, crashes after two calls. The code and environment is identical to the other thread, except use v0.1.14 of this package, and call the function twice in the same program:

// ...
for (let i = 0; i < 2; i++) {
  (async () => {
    const stream = true;
    // ...
  })();
}

Expected output

Two streamed responses with no errors.

Actual output

SpoliatioEarumConicioCollum
<omitted system path>/node_modules/openai/core.js:292
            throw new error_1.APIConnectionError({ cause: response });
                  ^

APIConnectionError: Connection error.
    at OpenAI.makeRequest (<omitted system path>/node_modules/openai/core.js:292:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async <omitted system path>/test.js:12:22 {
  status: undefined,
  headers: undefined,
  request_id: undefined,
  error: undefined,
  code: undefined,
  param: undefined,
  type: undefined,
  cause: FetchError: request to https://api.openai.com/v1/chat/completions failed, reason: Nock: No match for request {
    "method": "POST",
    "url": "https://api.openai.com/v1/chat/completions",
    "headers": {
      "content-length": [
        "134"
      ],
      "accept": [
        "application/json"
      ],
      "content-type": [
        "application/json"
      ],
      "user-agent": [
        "OpenAI/JS 4.48.2"
      ],
      "x-stainless-lang": [
        "js"
      ],
      "x-stainless-package-version": [
        "4.48.2"
      ],
      "x-stainless-os": [
        "Linux"
      ],
      "x-stainless-arch": [
        "x64"
      ],
      "x-stainless-runtime": [
        "node"
      ],
      "x-stainless-runtime-version": [
        "v20.11.1"
      ],
      "authorization": [
        "Bearer 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"
      ],
      "accept-encoding": [
        "gzip,deflate"
      ]
    },
    "body": "{\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"hello\"\n    }\n  ],\n  \"model\": \"gpt-4-turbo-preview\",\n  \"stream\": true\n}"
  }
      at OverriddenClientRequest.<anonymous> (<omitted system path>/node_modules/node-fetch/lib/index.js:1501:11)
      at OverriddenClientRequest.emit (node:events:518:28)
      at Socket.<anonymous> (<omitted system path>/node_modules/propagate/index.js:64:17)
      at Socket.emit (node:events:518:28)
      at <omitted system path>/node_modules/nock/lib/socket.js:101:14
      at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
    type: 'system',
    errno: 'ERR_NOCK_NO_MATCH',
    code: 'ERR_NOCK_NO_MATCH'
  }
}

Node.js v20.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions