Skip to content

Consistent node-fetch usage (also fixes ECONNRESET error) #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

nicky1038
Copy link
Contributor

@nicky1038 nicky1038 commented Mar 15, 2024

There is an issue with the current version of swagger-typescript-api. After successful generation of the file, indicated by this message:

✅ typescript api file [FILE] created in [FOLDER]

the execution does not stop. After some seconds of waiting I get this error in my console, and only then the utility stops.

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

I've discovered that the reason is node-fetch-h2 package, just changing it to node-fetch solved the issue.

Moreover, right now there are some inconsistencies with using node-fetch and node-fetch-h2 in the project:

  • node-fetch-h2 is used in the code but it is not stated in package.json
  • node-fetch v3 is stated in package.json, it is used only for typings; v3 could not be used in this project as it uses ESM.

My solution is to use only node-fetch, the latest v2 version. With my fix its usage now looks as expected and also works good without any errors.

@nicky1038 nicky1038 changed the title consistent node-fetch usage (also fixes ECONNRESET error) Consistent node-fetch usage (also fixes ECONNRESET error) Mar 15, 2024
@smorimoto
Copy link
Collaborator

In #727, this fix is going to get covered, and node-fetch has been replaced with native fetch. Thanks a lot @nicky1038!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants