Conversation
Both `socket.bind()` overloads and `socket.close()` return the socket
itself, but neither documents a return value, while `socket.ref()` and
`socket.unref()` in the same file already document
`Returns: {dgram.Socket}`.
Verified against lib/dgram.js, where every terminal path of
`Socket.prototype.bind()` and `Socket.prototype.close()` returns
`this`, and at runtime on v22.14.0, where `s.bind(0) === s`,
`s.bind({ port: 0 }) === s` and `s.close() === s`.
Signed-off-by: BIGSUS24 <152616194+BIGSUS24@users.noreply.github.com>
Assisted-by: a closed-source coding agent
Collaborator
|
Review requested:
|
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The documentation matches existing behavior and has no unresolved review comments.
Review effort: Lite
Findings: None
What changed in this PR
Documents existing return values for dgram.Socket methods.
Changes:
- Documents
{dgram.Socket}returns for bothbind()overloads. - Documents the
{dgram.Socket}return forclose().
| File | Summary |
|---|---|
doc/api/dgram.md |
Documents socket return values for bind() and close(). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both
socket.bind()overloads andsocket.close()return the socket itself, but the docs for all three don't mention a return value.socket.ref()andsocket.unref()a few sections down already documentReturns: {dgram.Socket}, so this is an inconsistency insidedgram.mdrather than a new convention.How I verified this
Against the source, on current
main:Socket.prototype.bind()ends withreturn this;, and each of its early exits (replaceHandlepath, cluster path,fdpath) also returnsthis. The barereturn;statements are inside the asyncstate.handle.lookup()callback, not the outer function, sobind()returns the socket on every path.Socket.prototype.close()returnsthison both its paths (queued and immediate).At runtime on v22.14.0:
Not included
socket.setTTL(),socket.setMulticastTTL()andsocket.setMulticastLoopback()also return a value (their own argument), but that looks like a legacy quirk —setMulticastLoopbackis literally annotated// 0.4 compatibilityinlib/dgram.js. I left those alone rather than pin down behaviour that may not be intended as API. Happy to add them if you'd prefer the file to be exhaustive.Disclosure per AGENTS.md: I used a coding agent (Claude Code) to scan
doc/api/*.mdagainstlib/for documented methods with undocumented return values. I read each hit in the source myself and ran the runtime checks above before opening this; the exclusions above are my own call.