socket.io
Advanced tools
Comparing version 2.4.1 to 2.5.0
@@ -0,1 +1,13 @@ | ||
# [2.5.0](https://github.com/socketio/socket.io/compare/2.4.1...2.5.0) (2022-06-26) | ||
### Bug Fixes | ||
* fix race condition in dynamic namespaces ([05e1278](https://github.com/socketio/socket.io/commit/05e1278cfa99f3ecf3f8f0531ffe57d850e9a05b)) | ||
* ignore packet received after disconnection ([22d4bdf](https://github.com/socketio/socket.io/commit/22d4bdf00d1a03885dc0171125faddfaef730066)) | ||
* only set 'connected' to true after middleware execution ([226cc16](https://github.com/socketio/socket.io/commit/226cc16165f9fe60f16ff4d295fb91c8971cde35)) | ||
* prevent the socket from joining a room after disconnection ([f223178](https://github.com/socketio/socket.io/commit/f223178eb655a7713303b21a78f9ef9e161d6458)) | ||
## [2.4.1](https://github.com/socketio/socket.io/compare/2.4.0...2.4.1) (2021-01-07) | ||
@@ -2,0 +14,0 @@ |
@@ -71,3 +71,2 @@ | ||
if (dynamicNsp) { | ||
debug('dynamic namespace %s was created', dynamicNsp.name); | ||
this.doConnect(name, query); | ||
@@ -74,0 +73,0 @@ } else { |
@@ -185,7 +185,13 @@ 'use strict'; | ||
nextFn.value(name, query, (err, allow) => { | ||
if (err || !allow) { | ||
run(); | ||
} else { | ||
fn(this.parentNsps.get(nextFn.value).createChild(name)); | ||
if (err || !allow) { | ||
return run(); | ||
} | ||
if (this.nsps[name]) { | ||
// the namespace was created in the meantime | ||
debug("dynamic namespace %s already exists", name); | ||
return fn(this.nsps[name]); | ||
} | ||
const namespace = this.parentNsps.get(nextFn.value).createChild(name); | ||
debug("dynamic namespace %s was created", name); | ||
fn(namespace); | ||
}); | ||
@@ -192,0 +198,0 @@ }; |
@@ -166,21 +166,27 @@ | ||
process.nextTick(function(){ | ||
if ('open' == client.conn.readyState) { | ||
if (err) return socket.error(err.data || err.message); | ||
if ("open" !== client.conn.readyState) { | ||
debug("next called after client was closed - ignoring socket"); | ||
socket._cleanup(); | ||
return; | ||
} | ||
// track socket | ||
self.sockets[socket.id] = socket; | ||
if (err) { | ||
debug("middleware error, sending CONNECT_ERROR packet to the client"); | ||
socket._cleanup(); | ||
return socket.error(err.data || err.message); | ||
} | ||
// it's paramount that the internal `onconnect` logic | ||
// fires before user-set events to prevent state order | ||
// violations (such as a disconnection before the connection | ||
// logic is complete) | ||
socket.onconnect(); | ||
if (fn) fn(); | ||
// track socket | ||
self.sockets[socket.id] = socket; | ||
// fire user-set events | ||
self.emit('connect', socket); | ||
self.emit('connection', socket); | ||
} else { | ||
debug('next called after client was closed - ignoring socket'); | ||
} | ||
// it's paramount that the internal `onconnect` logic | ||
// fires before user-set events to prevent state order | ||
// violations (such as a disconnection before the connection | ||
// logic is complete) | ||
socket.onconnect(); | ||
if (fn) fn(); | ||
// fire user-set events | ||
self.emit('connect', socket); | ||
self.emit('connection', socket); | ||
}); | ||
@@ -187,0 +193,0 @@ }); |
@@ -69,4 +69,4 @@ | ||
this.acks = {}; | ||
this.connected = true; | ||
this.disconnected = false; | ||
this.connected = false; | ||
this.disconnected = true; | ||
this.handshake = this.buildHandshake(query); | ||
@@ -304,2 +304,4 @@ this.fns = []; | ||
debug('socket connected - writing packet'); | ||
this.connected = true; | ||
this.disconnected = false; | ||
this.nsp.connected[this.id] = this; | ||
@@ -450,3 +452,3 @@ this.join(this.id); | ||
this.emit('disconnecting', reason); | ||
this.leaveAll(); | ||
this._cleanup(); | ||
this.nsp.remove(this); | ||
@@ -531,3 +533,7 @@ this.client.remove(this); | ||
} | ||
emit.apply(self, event); | ||
if (self.connected) { | ||
emit.apply(self, event); | ||
} else { | ||
debug("ignore packet received after disconnection"); | ||
} | ||
}); | ||
@@ -577,1 +583,6 @@ } | ||
}; | ||
Socket.prototype._cleanup = function () { | ||
this.leaveAll(); | ||
this.join = function noop() {}; | ||
} |
{ | ||
"name": "socket.io", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "node.js realtime framework server", | ||
@@ -28,6 +28,6 @@ "keywords": [ | ||
"debug": "~4.1.0", | ||
"engine.io": "~3.5.0", | ||
"engine.io": "~3.6.0", | ||
"has-binary2": "~1.0.2", | ||
"socket.io-adapter": "~1.1.0", | ||
"socket.io-client": "2.4.0", | ||
"socket.io-client": "2.5.0", | ||
"socket.io-parser": "~3.4.0" | ||
@@ -34,0 +34,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57877
1472
+ Addedengine.io@3.6.2(transitive)
+ Addedsocket.io-client@2.5.0(transitive)
- Removedengine.io@3.5.0(transitive)
- Removedsocket.io-client@2.4.0(transitive)
- Removedws@7.4.6(transitive)
Updatedengine.io@~3.6.0
Updatedsocket.io-client@2.5.0