-
Notifications
You must be signed in to change notification settings - Fork 19
Cannot read property 'on' of undefined - feathers-authentication-client #12
Comments
I think the issue is that there is a race condition happening. It looks like So the event listener is registered before a connection has been established and therefore |
@MHerszak mentioned that he changed |
I had the same problem because I had to open the socket later, I had to make my We could have something like this here (https://github.com/feathersjs/feathers-authentication-client/blob/master/src/passport.js#L55L77): function socketUpgradeHandle() {
socket.io.engine.on('upgrade', () => {
debug('Socket upgrading');
// If socket was already authenticated then re-authenticate
// it with the server automatically.
if (socket.authenticated) {
const data = {
strategy: this.options.jwtStrategy,
accessToken: app.get('accessToken')
};
this.authenticateSocket(data, socket, emit)
.then(this.setJWT)
.catch(error => {
debug('Error re-authenticating after socket upgrade', error);
socket.authenticated = false;
app.emit('reauthentication-error', error);
});
}
});
}
if (socket.io) {
if (socket.connected) {
socketUpgradeHandle();
} else {
socket.on('connect', socketUpgradeHandle);
}
} |
I have autoConnect: false and I face the same issue. Should this be fixed, or I need to solve it with some workaround like the guy above? |
@mihailp This one's still open. The code here needs to be moved https://github.com/feathersjs/feathers-authentication-client/blob/master/src/passport.js#L56. I'm just not sure where, yet. |
Should be closed via #20 |
Hi there,
I am having an issue with a package called
feathers-authentication-client
.I am getting the following error:
Cannot read property 'on' of undefined
which points to
feathers-authentication-client/lib/passport.js:80
and results in ->
socket.io.engine.on('upgrade', function () {
.I can only guess,
engine
seems to be undefined?Module versions
"feathers-authentication-client": "^0.1.3",
NodeJS version:
v6.9.1
Operating System:
macOs Sierra -v 10.12.1
The text was updated successfully, but these errors were encountered: