Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update server.js to fix [email protected] breaking changes #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

netop
Copy link

@netop netop commented May 18, 2017

Update server.js due to [email protected] Breaking changes that removes the upgradeReq from the WebSocket
object

websockets/ws#1099
websockets/ws#1104

@@ -20,7 +20,8 @@ app._initializeWSS = function(server) {
// Create WebSocket server as well.
this._wss = new WebSocketServer({ path: path, server: server});

this._wss.on('connection', function(socket) {
this._wss.on('connection', function(socket, req) {
socket.upgradeReq = req;
var query = url.parse(socket.upgradeReq.url, true).query;
Copy link

@lpinca lpinca May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the only place where upgradeReq is used it is probably better to use:

var query = url.parse(req ? req.url : socket.upgradeReq.url, true).query;

and remove the previous line. This will work with all ws versions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the ws dependency version to 3.0.0 as well.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants