I am getting this issue in session when i travel from one specific page to other, what can be the reason behind it
_http_outgoing.js:138
this.outputSize += this._header.length;
^
TypeError: Cannot read property 'length' of null
at ServerResponse.OutgoingMessage._send (_http_outgoing.js:138:38)
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:492:16)
at ServerResponse.OutgoingMessage.end (_http_outgoing.js:589:10)
at writeend (/home/...../my_app/node_modules/express-session/index.js:261:22)
at Immediate.onsave (/home/...../my_app/node_modules/express-session/index.js:335:11)
at runCallback (timers.js:666:20)
at tryOnImmediate (timers.js:639:5)
at processImmediate [as _immediateCallback] (timers.js:611:5)
Hi @mohanen I'm not 100% sure if that is an issue with this module or not. I can dig in, but need information to reproduce the issue. If you're not sure where to start, please provide the following:
Hi @dougwilson ,
I found the issue its due to the 404 error handling i wrote which messed up with WebSocket GET handshake
router.get('*', function(req, res) {
res.status(404).send('Page NOT Found -_-\'');
});
Thanks and Regards.
Hi,
I occasionally get this exact error and I also have WebSockets in my application.
But why does that code cause this issue? And what did you change to make it work properly>
As far as my understanding, if you have a web socket in a path say
You connect to it with
ws://www.somesite.com/ws_sample:3000
basically web sockets are upgraded http requests , so a http request is made to www.somesite.com/ws_sample:3000
In this case if you have a 404 error handlers it messes up with this request since that path "ws_sample" has not defined for http response .
Try removing any error handlers like app.get('*',....
or if you have any middle ware app.use(ThirdParty404ErrorHandler)
Oh thank you, I think that I have found it.
I have the following error handler at the bottom of my app file
app.use(function (err, req, res) {
log.error('Error on path %s\n%s\n', req.url, err.stack);
res.status(500).send((process.env.NODE_ENV == 'production') ? 'Internal Server Error' : err.stack.replace(/(?:\r\n|\r|\n)/g, '<br />'));
});
And for some reason I never noticed the following line in my log, just before it crashes:
2017-07-12T11:19:57.796Z - error: Error on path /players/.websocket?id={{the_id}}
My guess is that ever so often the handshake fails and that this is when the error handler is invoked.
@Vinno97 provided some valuable information over in the Express repo. If you're encountering this issue and using the express-ws module, you can follow the issue in the tracker at https://github.com/HenningM/express-ws/issues/64
Most helpful comment
Hi @dougwilson ,
I found the issue its due to the 404 error handling i wrote which messed up with WebSocket GET handshake
Thanks and Regards.