magda-io / magda

A federated, open-source data catalog for all your big data and small data
https://magda.io
Apache License 2.0
496 stars 93 forks source link

Investigate whether gateway will restart for losing connection of proxy target #3495

Closed t83714 closed 8 months ago

t83714 commented 9 months ago

Investigate whether gateway will restart for losing connection of proxy target

We saw some errors like:

Error: socket hang up
    at connResetException (internal/errors.js:639:14)
    at Socket.socketCloseListener (_http_client.js:449:25)
    at Socket.emit (events.js:412:35)
    at TCP.<anonymous> (net.js:686:12)

in Magda gateway logs.

We need to make sure those errors are ignored rather than causing restarts

t83714 commented 9 months ago

Update: socket hang up error are ingored. But ERR_HTTP_HEADERS_SENT error will cause restarts:

_http_outgoing.js:561
    throw new ERR_HTTP_HEADERS_SENT('set');
    ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (internal/errors.js:322:7)
    at ServerResponse.setHeader (_http_outgoing.js:561:11)
    at setHeadersFromObject (/usr/src/app/node_modules/on-headers/index.js:94:16)
    at ServerResponse.setWriteHeadHeaders (/usr/src/app/node_modules/on-headers/index.js:122:5)
    at ServerResponse.writeHead (/usr/src/app/node_modules/on-headers/index.js:30:36)
    at ProxyServer.<anonymous> (/usr/src/app/component/dist/createBaseProxy.js:88:9)
    at ProxyServer.emit (/usr/src/app/node_modules/eventemitter3/index.js:210:27)
    at ClientRequest.proxyError (/usr/src/app/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:165:18)
    at ClientRequest.emit (events.js:400:28)
    at Socket.socketErrorListener (_http_client.js:475:9) {
  code: 'ERR_HTTP_HEADERS_SENT'
}
t83714 commented 8 months ago

closed via PR: https://github.com/magda-io/magda/pull/3497