qcobjects-cli
Advanced tools
Comparing version 0.1.27 to 0.1.28
@@ -278,13 +278,18 @@ /** | ||
CONFIG.set('backendTimeout',CONFIG.get('backendTimeout') || 20000); | ||
server.setTimeout(CONFIG.get('backendTimeout'), ()=>{ | ||
var timeoutHandler = ()=>{ | ||
// end the stream on timeout | ||
try { | ||
logger.info('A timeout occurred...' + CONFIG.get('backendTimeout').toString()); | ||
logger.info('Killing session...'); | ||
res.respond([{ | ||
':status': 408, | ||
'content-type': 'text/html' | ||
}]); | ||
res.write('<h1>408 - REQUEST TIMEOUT</h1>'); | ||
res.end(); | ||
if (!res.destroyed){ | ||
logger.info('A timeout occurred...' + CONFIG.get('backendTimeout').toString()); | ||
logger.info('Killing session...'); | ||
res.writeHeader( 500, { | ||
'content-type': 'text/html' | ||
}); | ||
res.on('error',()=>{}); | ||
res.write('<h1>500 - INTERNAL SERVER ERROR (TIMEOUT)</h1>'); | ||
res.end(); | ||
} else { | ||
logger.debug('Session was normally finishing...'); | ||
} | ||
}catch (e){ | ||
@@ -294,4 +299,9 @@ logger.debug('An unhandled error occurred during timeout catching...'); | ||
} | ||
}); | ||
server.removeListener('timeout',timeoutHandler); | ||
}; | ||
if (!res.destroyed){ | ||
server.setTimeout(CONFIG.get('backendTimeout'), timeoutHandler); | ||
} | ||
if (this.request.pathname.indexOf('.')<0){ | ||
@@ -298,0 +308,0 @@ this.request.scriptname = CONFIG.get('documentRootFileIndex'); |
@@ -209,3 +209,3 @@ /** | ||
stream.session.setMaxListeners(9999999999); | ||
stream.session.on('timeout', () => { | ||
var timeoutHandler = () => { | ||
// end the stream on timeout | ||
@@ -217,6 +217,7 @@ try { | ||
stream.respond([{ | ||
':status': 408, | ||
':status': 500, | ||
'content-type': 'text/html' | ||
}]); | ||
stream.write('<h1>408 - REQUEST TIMEOUT</h1>'); | ||
stream.on('error',()=>{}); | ||
stream.write('<h1>500 - INTERNAL SERVER ERROR (TIMEOUT)</h1>'); | ||
stream.end(); | ||
@@ -227,10 +228,17 @@ } else { | ||
}catch(e){ | ||
logger.info('An unhandled error occurred during timeout catching...'); | ||
logger.info(e.message); | ||
logger.debug('An unhandled error occurred during timeout catching...'); | ||
logger.debug(e.message); | ||
} | ||
}); | ||
if (!stream.destroyed){ | ||
stream.session.removeListener('timeout',timeoutHandler); | ||
} else { | ||
server.removeListener('timeout',timeoutHandler); | ||
} | ||
}; | ||
if (!stream.destroyed){ | ||
stream.session.on('timeout', timeoutHandler ); | ||
} | ||
stream.session.altsvc('h2=":8000"', stream.id); | ||
@@ -268,2 +276,3 @@ stream.session.altsvc('https=":'+CONFIG.get('serverPortHTTPS')+'"', stream.id); | ||
route:route, | ||
server:server, | ||
stream:stream, | ||
@@ -270,0 +279,0 @@ request:request |
{ | ||
"name": "qcobjects-cli", | ||
"version": "0.1.27", | ||
"version": "0.1.28", | ||
"description": "qcobjects cli command line tool", | ||
@@ -5,0 +5,0 @@ "main": "qcobjects-cli.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67092
1492