got: RequestError: read ECONNRESET in new version of got

Describe the bug

  • Node.js version: v12.13.0
  • OS & version: Linux

Actual behavior

Got throw a ReuestError in request in latest version.

GotError: read ECONNRESET
    at onError (/home/fengkx/project/NodeRSSBot/node_modules/got/dist/source/request-as-event-emitter.js:138:29)
    at handleRequest (/home/fengkx/project/NodeRSSBot/node_modules/got/dist/source/request-as-event-emitter.js:171:17)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:201:27)

Expected behavior

request success and no throw happen

Code to reproduce

This error is thrown when I use got in NodeRSSBot. for example https://github.com/fengkx/NodeRSSBot/blob/master/middlewares/test-url.js#L17

I am sorry I cannot provide a simple code to reproduce the problem.

I try to extract out the logic to a simple script. But the error just disappear when I do this. But I can reproduce the problem every single time my bot try to make a request in both my laptop and VPS.

I am pretty sure I have read the release not of version 10 and made the migration to my code. And I try using const got = require('got') directly rather than make my instance using got.extend too.

Try to narrow down the problem

This problem didn’t show up in version 9.6.0

So I try to narrow down the problem a bit. I installed several versions of got from 9.6.0 to 10.0.3. And find that the problem start to show up in version 10.0.0-beta.1

Then I try to compile got commit by commit and find the problem start to show up from 518f0f5

But I can’t figure out what’s going on. Any idea?

full err that I caught: https://paste.ubuntu.com/p/YxBxFpg7Bc/ Hope to help😓

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

I have already pasted the full error I caught in ubuntu pastebin above. It is JSON serialized. The console.log version of err.options below. In fact my code is using the default instance const got = require('got') and pass no option got.get(URL_STRING)

{
  headers: { 'user-agent': 'got (https://github.com/sindresorhus/got)' },
  prefixUrl: [Getter/Setter],
  hooks: {
    beforeError: [],
    init: [],
    beforeRequest: [],
    beforeRedirect: [],
    beforeRetry: [],
    afterResponse: []
  },
  timeout: {},
  retry: {
    calculateDelay: [Function: calculateDelay],
    limit: 2,
    methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
    statusCodes: [
      408, 413, 429,
      500, 502, 503,
      504
    ],
    errorCodes: [
      'ETIMEDOUT',
      'ECONNRESET',
      'EADDRINUSE',
      'ECONNREFUSED',
      'EPIPE',
      'ENOTFOUND',
      'ENETUNREACH',
      'EAI_AGAIN'
    ],
    maxRetryAfter: Infinity
  },
  method: 'GET',
  maxRedirects: 10,
  decompress: true,
  throwHttpErrors: true,
  followRedirect: true,
  isStream: false,
  cache: false,
  dnsCache: false,
  useElectronNet: false,
  responseType: 'text',
  resolveBodyOnly: false,
  methodRewriting: true,
  ignoreInvalidCookies: false,
  url: URL {
    href: 'https://0xffff.one/atom',
    origin: 'https://0xffff.one',
    protocol: 'https:',
    username: '',
    password: '',
    host: '0xffff.one',
    hostname: '0xffff.one',
    port: '',
    pathname: '/atom',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  }
}