You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type error when using socket.timeout.emitWithAck #4925
Expected behavior r2 should also be inferred as Promise<number>.
Platform:
Typescript version: 5.3.3
Additional context
The return type of emitWithAck is from Promise<FirstArg<Last<EventParams<EmitEvents, Ev>>>>, which picks the first argument of cb. However, timeout uses DecorateAcknowledgements then PrependTimeoutError, which prepend a Error type param to cb, so this FirstArg will focus on the error instead of the real return value.
Maybe replace FirstArg with a type LastArg<T> = T extends (...args: infer Args) => any ? Args extends [] ? never : Args extends [...infer _, infer Last] ? Last : never : never; will solve this issue? I'm not so familiar with the js logic, so just a hypothesis.
By the way, I have found the same problem in #4813 , it can be solved by using socket options ackTimeout in the client side (I have already adopted this solution). But I think it's better if this problem can be solved completely.
Activity
darrachequesne commentedon Jan 22, 2024
You are right, we need to apply the same changes on the client side: #4817
GStarP commentedon Jan 22, 2024
Oh sorry, I should post this issue in the client side repo.
Thanks for answering, I will close this issue and look forward to the new version client.
DudaGod commentedon Apr 11, 2024
Hello. Do I understand correctly that this is not supported on the client yet? When can I expect a new version?
Thanks.
MiloWang2048 commentedon Jun 29, 2024
I can reproduce this error with socket.io version 4.7.5, on server side, with or without timeout() call.
But socket.emit() works just fine.