Cannot call addListener on the client service connection
See original GitHub issueSteps to reproduce
Listen to events like this:
app.service('myservice').watch({ listStrategy: 'smart' })
.find({ query })
.subscribe(response => { ... })
Expected behavior
No error is raised, the same code worked fine with Feathers v3.
Actual behavior
The following error is raised with either Feathers v4 or v5:
I’ve tried to dig into what is going on but I do not really understand the code fully. As far as I understand feathers services implement this mixin. The transport abstraction expects that the underlying connection also implements a similar interface. But as far as I can see, the connection object, which is a Socket for socket.io, implements a slightly different interface. For instance if I debug our app, I can see that the connection object has a addEventListener
method but not a addListener
method as expected. Could it be linked to a change in interface within socket.io ?
System configuration
NodeJS version 16, Webpack 5, Feathers v4 or v5
"@feathersjs/client": "^5.0.0-pre.22"
"feathers-reactive": "^0.9.0"
"socket.io-client": "^4.4.1"
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:13 (11 by maintainers)
Top GitHub Comments
@RobMaple Yep, that was totally it. I am seeing the same error now. It appears that a Socket.io socket still isn’t Node Event Emitter compatible and does not have the addListener method. The following fixes it:
This should probably just be aliased in the client so that the service is fully event emitter compatible.
You are right, I did not have a look to these tests. So I started https://github.com/feathersjs-ecosystem/feathers-reactive/pull/192 and the behavior seems to me a little strange but maybe my tests are not right.
It seems that the reactive listener is correctly called when the client initiates the service operations itself but not when they are initiated server-side. It seems to be almost the case when initiated by another client except the created event that is missed in the test. Any insight is welcome @daffl.