Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res.redirect(location)
break
case 'render':
console.log(`[${requestId}][render] Rendering ISO response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.success', 1)
res.send(body)
saveResponseToCache(cacheKey, body, postIds, postTokens, streamKind, streamId)
break
case 'error':
console.log(`[${requestId}][render] Rendering error response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.error', 1)
res.status(500).end()
break
case '404':
console.log(`[${requestId}][render] Rendering 404 response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.404', 1)
res.status(404).end()
break
default:
console.log(`[${requestId}][render] Received unrecognized response (took ${new Date() - startTime}ms)`)
console.log(JSON.stringify(result))
librato.measure('webapp.server.render.error', 1)
// Fall through
res.status(500).end()
}
clearTimeout(renderTimeout)
}
const jobFailedCallback = (errorMessage) => {
saveResponseToCache(cacheKey, body, postIds, postTokens, streamKind, streamId)
break
case 'error':
console.log(`[${requestId}][render] Rendering error response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.error', 1)
res.status(500).end()
break
case '404':
console.log(`[${requestId}][render] Rendering 404 response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.404', 1)
res.status(404).end()
break
default:
console.log(`[${requestId}][render] Received unrecognized response (took ${new Date() - startTime}ms)`)
console.log(JSON.stringify(result))
librato.measure('webapp.server.render.error', 1)
// Fall through
res.status(500).end()
}
clearTimeout(renderTimeout)
}
const jobFailedCallback = (errorMessage) => {
const jobFailedCallback = (errorMessage) => {
libratoDone()
console.log(`[${requestId}][render] Job failed (took ${new Date() - startTime}ms)`, JSON.stringify(errorMessage))
res.send(indexStr)
librato.measure('webapp.server.render.timeout', 1)
clearTimeout(renderTimeout)
}
const jobCompleteCallback = (result) => {
libratoDone()
const { type, location, body, postIds, postTokens, streamKind, streamId } = (result || {})
switch (type) {
case 'redirect':
console.log(`[${requestId}][render] Redirecting to ${location} (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.redirect', 1)
res.redirect(location)
break
case 'render':
console.log(`[${requestId}][render] Rendering ISO response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.success', 1)
res.send(body)
saveResponseToCache(cacheKey, body, postIds, postTokens, streamKind, streamId)
break
case 'error':
console.log(`[${requestId}][render] Rendering error response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.error', 1)
res.status(500).end()
break
case '404':
console.log(`[${requestId}][render] Rendering 404 response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.404', 1)
const renderTimeout = setTimeout(() => {
console.log(`[${requestId}] Render timed out after ${renderProcessTimeout}s; killing child process.`)
librato.measure('webapp.server.render.timeout.child_process', 1)
if (child) {
child.kill('SIGKILL')
}
done(null)
}, renderProcessTimeout * 1000)
const jobCompleteCallback = (result) => {
libratoDone()
const { type, location, body, postIds, postTokens, streamKind, streamId } = (result || {})
switch (type) {
case 'redirect':
console.log(`[${requestId}][render] Redirecting to ${location} (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.redirect', 1)
res.redirect(location)
break
case 'render':
console.log(`[${requestId}][render] Rendering ISO response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.success', 1)
res.send(body)
saveResponseToCache(cacheKey, body, postIds, postTokens, streamKind, streamId)
break
case 'error':
console.log(`[${requestId}][render] Rendering error response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.error', 1)
res.status(500).end()
break
case '404':
console.log(`[${requestId}][render] Rendering 404 response (took ${new Date() - startTime}ms)`)
librato.measure('webapp.server.render.404', 1)
res.status(404).end()
break
default:
console.log(`[${requestId}][render] Received unrecognized response (took ${new Date() - startTime}ms)`)
console.log(JSON.stringify(result))
queue.inactiveCount((err, total) => {
if (!err) {
librato.measure('kue.inactive.count', total)
}
})
queue.activeCount((err, total) => {
queue.completeCount((err, total) => {
if (!err) {
librato.measure('kue.complete.count', total)
}
})
}, 30 * 1000);
queue.activeCount((err, total) => {
if (!err) {
librato.measure('kue.active.count', total)
}
})
queue.failedCount((err, total) => {
queue.failedCount((err, total) => {
if (!err) {
librato.measure('kue.failed.count', total)
}
})
queue.completeCount((err, total) => {