You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am using your mvc solution and I get the [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client error sometimes.
Here is an example:
0|server | Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
0|server | at ServerResponse.setHeader (_http_outgoing.js:470:11)
0|server | at ServerResponse.header (/var/www/scrapper-node/node_modules/express/lib/response.js:767:10)
0|server | at ServerResponse.send (/var/www/scrapper-node/node_modules/express/lib/response.js:170:12)
0|server | at done (/var/www/scrapper-node/node_modules/express/lib/response.js:1004:10)
0|server | at tryHandleCache (/var/www/scrapper-node/node_modules/ejs/lib/ejs.js:257:5)
0|server | at View.exports.renderFile [as engine] (/var/www/scrapper-node/node_modules/ejs/lib/ejs.js:482:10)
0|server | at View.render (/var/www/scrapper-node/node_modules/express/lib/view.js:135:8)
0|server | at tryRender (/var/www/scrapper-node/node_modules/express/lib/application.js:640:10)
0|server | at Function.render (/var/www/scrapper-node/node_modules/express/lib/application.js:592:3)
0|server | at ServerResponse.render (/var/www/scrapper-node/node_modules/express/lib/response.js:1008:7)
0|server | at ServerResponse.res.render (/var/www/scrapper-node/node_modules/express-flash/lib/express-flash.js:29:16)
0|server | at ServerResponse.res.render (/var/www/scrapper-node/app/kernel.js:129:20)
0|server | at index (/var/www/scrapper-node/app/controllers/VideoController.js:13:28)
0|server | at process._tickCallback (internal/process/next_tick.js:68:7)
VideoController.js looks like this:
module.exports = {
/**
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
index: async(req, res, next) => {
const id = req.params.id
if(typeof id === 'undefined') return res.notFound('Invalid video id')
try {
const cached = await CacheService.get(id)
if (cached) {
return res.render('video', JSON.parse(cached)) ### // Here is line 13
}
else {
const video = await Video.findById(id)
if (video === null) return res.notFound('Video not found')
const links = VideoStreamService.create(req, res, id, video)
if (links.status === 500) {
return res.notFound('No active sources found')
}
CacheService.set(id, JSON.stringify({
links: links.data
}))
return res.render('video', {
links: links.data
})
}
}
catch (err) {
// next(err)
return res.badRequest('Temporary error. Try again later or choose another mirror.')
}
},
}
The text was updated successfully, but these errors were encountered:
Hello,
I am using your mvc solution and I get the
[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
error sometimes.Here is an example:
VideoController.js looks like this:
The text was updated successfully, but these errors were encountered: