Skip to content

Commit a7fbd1a

Browse files
0xClpzdarrachequesne
authored andcommittedNov 20, 2018
[fix] Throw an error when trying to access the clients of a dynamic namespace (#3355)
Accessing the clients of a dynamic namespace throws because doing `io.of(/your-regex/g)` returns a namespace with no adapter and the clients methods tries to access `namespace.adapter.clients`.
1 parent 190d22b commit a7fbd1a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
 

‎lib/namespace.js

+3
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ Namespace.prototype.write = function(){
262262
*/
263263

264264
Namespace.prototype.clients = function(fn){
265+
if(!this.adapter){
266+
throw new Error('No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?')
267+
}
265268
this.adapter.clients(this.rooms, fn);
266269
// reset rooms for scenario:
267270
// .in('room').clients() (GH-1978)

0 commit comments

Comments
 (0)
Please sign in to comment.