Skip to content
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

Question : Why do we need global-agent at all? #66

Open
MaciekLeks opened this issue Nov 17, 2023 · 0 comments
Open

Question : Why do we need global-agent at all? #66

MaciekLeks opened this issue Nov 17, 2023 · 0 comments

Comments

@MaciekLeks
Copy link

MaciekLeks commented Nov 17, 2023

Hi,

We experienced significant issues with an older version of the axios package and our corporate proxy. Starting from a certain point in time, every second execution of some code would finish with an error. Before that, it occurred randomly:

Error: socket hang up
    at connResetException (node:internal/errors:721:14)
    at Socket.socketOnEnd (node:_http_client:519:23)
    at Socket.emit (node:events:526:35)
    at endReadableNT (node:internal/streams/readable:1408:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ECONNRESET',
config: {
    url: '[https://[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results?locator=MTAwMDAw&maxRecords=20000'](https://[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results?locator=MTAwMDAw&maxRecords=20000%27),
    method: 'get',
    headers: {
      Accept: 'text/csv',
      'Content-Type': 'application/json',
      Authorization: 'Bearer [redacted]',
      'User-Agent': 'axios/0.21.4',
      host: '[redacted]'
    },
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    adapter: [Function: httpAdapter],
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: Infinity,
    maxBodyLength: Infinity,
    validateStatus: [Function: validateStatus],
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    data: undefined
  },
  request: <ref *1> Writable {
    _writableState: WritableState {
      state: 802924,
      highWaterMark: 16384,
      defaultEncoding: 'utf8',
      length: 0,
      corked: 0,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      pendingcb: 0,
      errored: null,
      [Symbol(kOnFinished)]: []
    },
    _events: [Object: null prototype] {
      response: [Function: handleResponse],
      error: [Function: handleRequestError]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    _options: {
      maxRedirects: 21,
      maxBodyLength: Infinity,
      protocol: 'http:',
      path: '[https://[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results?locator=MTAwMDAw&maxRecords=20000'](https://[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results?locator=MTAwMDAw&maxRecords=20000%27),
      method: 'GET',
      headers: [Object],
      agent: undefined,
      agents: [Object],
      auth: undefined,
      hostname: '[proxy-host-redacted]',
      port: '3128',
      beforeRedirect: [Function: beforeRedirect],
      nativeProtocols: [Object],
      pathname: '[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results',
      search: '?locator=MTAwMDAw&maxRecords=20000'
    },
    _ended: true,
    _ending: true,
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 0,
    _requestBodyBuffers: [],
    _onNativeResponse: [Function (anonymous)],
    _currentRequest: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [Socket],
      _header: 'GET https://[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results?locator=MTAwMDAw&maxRecords=20000 HTTP/1.1\r\n' +
        'Accept: text/csv\r\n' +
        'Content-Type: application/json\r\n' +
        'Authorization: Bearer [redacted] +
        'User-Agent: axios/0.21.4\r\n' +
        'host: [redaced]\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: 'https://[redacted]/services/data/v59.0/jobs/query/7[500](https://[redacted]/results?locator=MTAwMDAw&maxRecords=20000',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: [Function: emitRequestTimeout],
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: true,
      host: 'gitlab-proxy.cybersec',
      protocol: 'http:',
      _redirectable: [Circular *1],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    _currentUrl: '[https://[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results?locator=MTAwMDAw&maxRecords=20000'](https://[redacted]/services/data/v59.0/jobs/query/7500D00000A4oZ0QAJ/results?locator=MTAwMDAw&maxRecords=20000%27),
    [Symbol(kCapture)]: false
  },
  response: undefined,
  isAxiosError: true,
  toJSON: [Function: toJSON]
}

When we enabled global-agent, all the problems disappeared. One of our colleague said that the problem lies in the infrastructure, not in axios itself.

Who is right? And why do you develop and maintain this "unnecessary" tool if the problem lies in the infrastructure? ;)

P.S. I'm not a Node.js expert. I'm responsible for the infrastructure, but I'm 100% sure that the packets were not reset (L4/TCP/RST), as suggested by the axios error below.

Best regards,
Maciek

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

No branches or pull requests

1 participant