tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.65k stars 510 forks source link

1.6.0 bug #473

Open infister opened 4 years ago

infister commented 4 years ago

Every few minutes a warning appears:

(node:1902) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:1902) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
at /usr/lib/node_modules/laravel-echo-server/dist/channels/presence-channel.js:71:31
at Array.filter (<anonymous>)
at /usr/lib/node_modules/laravel-echo-server/dist/channels/presence-channel.js:71:81
(node:1902) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'socketId' of undefined

I am using presence channels.

This is what I found here in 71 line:

PresenceChannel.prototype.leave = function (socket, channel) {
        var _this = this;
        this.getMembers(channel).then(function (members) {
            members = members || [];
            var member = members.find(function (member) { return member.socketId == socket.id; });
---->   members = members.filter(function (m) { return m.socketId != member.socketId; });
            _this.db.set(channel + ':members', members);
            _this.isMember(channel, member).then(function (is_member) {
                if (!is_member) {
                    delete member.socketId;
                    _this.onLeave(channel, member);
                }
            });
        }, function (error) { return log_1.Log.error(error); });
    };

Seems like member is undefined.


There is also another warning:

(node:3009) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)
at /usr/lib/node_modules/laravel-echo-server/dist/channels/presence-channel.js:59:27
at PresenceChannel.onJoin (/usr/lib/node_modules/laravel-echo-server/dist/channels/presence-channel.js:85:14)
(node:3009) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'broadcast' of undefined

This is exactly this line:

PresenceChannel.prototype.onJoin = function (socket, channel, member) {
        this.io
            .sockets
            .connected[socket.id]
            .broadcast  <----
            .to(channel)
            .emit('presence:joining', channel, member);
    };

connected[socket.id] is undefined

jhoanborges commented 4 years ago

same here

AhW00 commented 3 years ago

same here

jasparfitt commented 2 years ago

I'm also experiencing this issue, looks like there is even a pull request with a fix in https://github.com/tlaverdure/laravel-echo-server/pull/535 would be great if that could make it's way into a version