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

TypeError: Cannot convert undefined or null to object #4

Open
Figzyy opened this issue Sep 22, 2022 · 0 comments
Open

TypeError: Cannot convert undefined or null to object #4

Figzyy opened this issue Sep 22, 2022 · 0 comments

Comments

@Figzyy
Copy link

Figzyy commented Sep 22, 2022

I've ran into this issue. As soon as a socket is connected the server shuts down because of this error.
Not sure how this is happening.

1 function getAllPlayers(){
2    var players = [];
3    
4    Object.keys(io.sockets.connected).forEach(function(socketID){
5        var player = io.sockets.connected[socketID].player;
6        if(player) players.push(player);
7    });
8    return players;
}

Line 4 seems to be the issue.

TypeError: Cannot convert undefined or null to object
at Function.keys ()

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

No branches or pull requests

1 participant