Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

doc: which events are proxied through createWebSocketStream #2228

Closed
wants to merge 2 commits into from

Conversation

coolaj86
Copy link
Contributor

The documentation doesn't specify how the ws module stream maps to which type of Node Duplex Stream.

I assume that it behaves like a TCP Duplex Stream: https://nodejs.org/api/net.html#class-netsocket.

I also assume that the ping and pong and keepalive timeouts are proxied in a meaningful way.

@lpinca
Copy link
Member

lpinca commented Jun 11, 2024

I assume that it behaves like a TCP Duplex Stream

Yes, a plain https://nodejs.org/api/stream.html#class-streamduplex specifically.

I also assume that the ping and pong and keepalive timeouts are proxied in a meaningful way.

You can't send and receive pings/pongs from the wrapper Duplex, but they are correctly handled by the wrapped WebSocket.

Is it necessary to list the events? They are the standard Duplex events and I would prefer to not keep them in sync in ws documentation. The 'timeout' event is not emitted, see

if (socket.setTimeout) socket.setTimeout(0);
.

@coolaj86
Copy link
Contributor Author

coolaj86 commented Jun 27, 2024

Is it necessary to list the events? They are the standard Duplex events

I don't think that there are a standard set of events. I think it's all implementation specific - such as the use of 'end' vs 'close' and such. I think Duplexes are basically two-way EventEmitters, and can handle any arbitrary (hopefully documented) event.

If it's listed, it's clear what this implementation handles. If it's not listed, someone has to guess or read the code.

@lpinca
Copy link
Member

lpinca commented Jun 28, 2024

I don't think that there are a standard set of events. I think it's all implementation specific - such as the use of 'end' vs 'close' and such. I think Duplexes are basically two-way EventEmitters, and can handle any arbitrary (hopefully documented) event.

Yes there is standard set of events. See https://nodejs.org/api/stream.html. For a Duplex the set is events of Readable ∪ events of Writable. 'end' and 'close' have different meanings and they are used accordingly. There are no implementation specific events or they would have already been documented.

If it's not listed, someone has to guess or read the code.

They just have to read Node.js documentation where the events are listed.

@lpinca
Copy link
Member

lpinca commented Jul 2, 2024

I'm closing this as per #2228 (comment) and #2228 (comment). Thank you anyway.

@lpinca lpinca closed this Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants