node.js - ExpressJS uncaughtException: [TypeError: opt.expires.toUTCString is not a function] -
i'm getting following weird behaviour happens randomly , can't reproduce can "fix".
i have static webapp send file express api. i'm not sure it's best practice on router:
router.get('/', function(req, res, next) { var webappdir = path.join(__dirname, '..', '..','webappsimple'); //show user profile if(req.isauthenticated() || consts.webapp.debug == 1) { res.sendfile(webappdir + '/index.html'); //res.json({}); } //show signup else { res.redirect('/signup'); } });
then following error:
'typeerror: opt.expires.toutcstring not function', ' @ object.serialize (/users/andreymigalovich/projects_localmac/print-that-sheet/server/node_modules/express/node_modules/cookie/index.js:135:56)', ' @ serverresponse.res.cookie (/users/andreymigalovich/projects_localmac/print-that-sheet/server/node_modules/express/lib/response.js:804:36)', ' @ serverresponse.res.writehead (/users/andreymigalovich/projects_localmac/print-that-sheet/server/node_modules/express-session/index.js:168:11)', ' @ serverresponse._implicitheader (_http_server.js:157:8)', ' @ serverresponse.outgoingmessage.write (_http_outgoing.js:433:10)', ' @ readstream.ondata (_stream_readable.js:529:20)', ' @ emitone (events.js:90:13)', ' @ readstream.emit (events.js:182:7)', ' @ readableaddchunk (_stream_readable.js:147:16)', ' @ readstream.readable.push (_stream_readable.js:111:10)', ' @ onread (fs.js:1818:12)', ' @ fsreqwrap.wrapper [as oncomplete] (fs.js:614:17)'
if change res.sendfile(webappdir + '/index.html'); res.json({}); don't error , browser shows empty page (as should..)
the problem "fixed" when delete entire content on index.html page, refresh browser paste content again (without changing anything) , refresh browser again. doing fixes problem unknown amount of time.
i'm using nodejs v5.6.0 with: "express": "~4.13.1" , "express-session": "~1.0.0"
hoping better understanding of what's going on or change way send static files avoid whole issue.
Comments
Post a Comment