Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

client.ts > _packet() > writeToEngine() argument type #3775

Closed
david-fong opened this issue Jan 27, 2021 · 1 comment
Closed

client.ts > _packet() > writeToEngine() argument type #3775

david-fong opened this issue Jan 27, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@david-fong
Copy link
Contributor

Describe the bug
I do not know if this is a bug. I came across some code that doesn't seem to make sense from a typings point of view:
https://github.com/socketio/socket.io/blob/master/lib/client.ts#L182

writeToEngine is referenced at lines 193 where it is passed an argument of type any[], and at 196 where it is apssed an argument of type Packet. The inner function body of writeToEngine seems to expect to be passed Packet[]. Could you explain how this is working? If it just comes down to fixing type annotations, I would be happy to submit a PR for it once I understand the intended behaviour.

To Reproduce

Socket.IO server version: 3.1.0

@david-fong david-fong added the bug Something isn't working label Jan 27, 2021
darrachequesne added a commit to socketio/socket.io-adapter that referenced this issue May 10, 2021
A few notes:

- only the first element is pre-encoded, because the other elements are
buffers and will be sent as is over the WebSocket connection

- using `socket.packet()` was unexpectedly working, we will now use
`socket.client.writeToEngine()` (see [1])

See also: socketio/engine.io@7706b12

[1]: socketio/socket.io#3775
@darrachequesne
Copy link
Member

You are totally right, this worked but didn't make sense at all.

The adapter now calls socket.client.writeToEngine() instead of socket.packet(): socketio/socket.io-adapter@5579d40

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants