TypeScript error TS2339 Property 'remoteJoin' does not exist on type 'Adapter'.
Describe the bug Type error related to @socket.io/redis-adapter. remoteJoin or any other method of the redis adapter package throws a TS error.
error TS2339: Property 'remoteJoin' does not exist on type '{ (): AdapterConstructor | undefined;
(v: AdapterConstructor): Server<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap>; }'.
94 fastify.io.adapter.remoteJoin(
There is a small possibility that i just don't know how to make types match when this kind of internal related parts of the project is changed (like extending default adapter with a custom adapter) but I was using the same setup for JS project and there was no problem related to functionality. So I am thinking it's just my insufficient knowledge of TS, but i wanted to post an issue anyway
To Reproduce The same type error can be reproduced with this small project that i made: https://github.com/outranker/socket.io-redist-adapter-type-error-reproduce
To run the project, first npm run watch in the terminal and open new terminal and type npm run start
I am having the same issue. I can't figure out how to solve it. The only way I can get the "remoteJoin" method is by doing this:
const redisAdapter = createAdapter(pubClient, subClient);
redisAdapter("/").remoteJoin(...)
Did you find a solution?
No, i wasn't able to get this work properly so i dumped the redis adapter completely for the time being. It looks like this package has a bug or doesn't play nicely with fastify. In order to focus on the business logic of my app i decided to put a hold on using this package.
Also i didn't receive any response for this issue. Maybe because maintainer is too busy with other things or nobody could reproduce this issue?
Could you please try to reproduce this issue using the github repo that i mentioned above?
I actually tried to get it to work in spite of the error, and it works fine. My Vs Code continues telling me the error exists, but it works just fine
await io.of("/").adapter.remoteJoin(socketID, roomName)
Thank you for sharing your solution! I will give it a try when i get to my laptop
I will let you know how it goes in my app when i do try it
Please note that you can now use socketsJoin():
io.in(socketID).socketsJoin(roomName);
Reference: https://socket.io/docs/v4/server-api/#serversocketsjoinrooms
Thank you so much. Does it work even with apps with multiple nodes? I read the info in the documentation you provided and I don't think that is mentioned.
@komodoUSA yes, it does work with multiple nodes. I'll try to make that clearer in the documentation.