add more debugging logs

This commit is contained in:
Yaroslav Kukharuk
2021-01-19 16:39:05 +02:00
parent be2bef6f3f
commit b8c7a0c9c5
2 changed files with 11 additions and 2 deletions
+10 -2
View File
@@ -55,7 +55,7 @@ class Client extends EventEmitter {
this.emit('close');
}
handleRequest(req, res) {
handleRequest(req, res, retry = true) {
this.debug('> %s', req.url);
const opt = {
path: req.url,
@@ -74,6 +74,7 @@ class Client extends EventEmitter {
pump(clientRes, res, (err) => {
if (err) {
this.debug('> PIPE ERROR, %s', err);
this.debug(err);
}
});
});
@@ -83,14 +84,21 @@ class Client extends EventEmitter {
// if we have already sent headers?
clientReq.once('error', (err) => {
// TODO(roman): if headers not sent - respond with gateway unavailable
this.debug('ERROR < %s', req.url);
this.debug(' < ERROR %s', req.url);
this.debug(err);
this.debug(JSON.stringify( err ));
if (retry) {
this.debug('< RETRY');
this.handleRequest( req, res, false);
}
});
// using pump is deliberate - see the pump docs for why
pump(req, clientReq, (err) => {
if (err) {
this.debug('< PIPE ERROR, %s', err);
this.debug(err);
}
});
}
+1
View File
@@ -143,6 +143,7 @@ export default function(opt) {
const clientId = GetClientIdFromHostname(hostname);
if (!clientId) {
appCallback(req, res);
debug('ClientID for host %s was not found :(', hostname);
return;
}