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: add argument information for socket.destroy() #7238

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,17 @@ If `true` - [`socket.connect(options[, connectListener])`][`socket.connect(optio
haven't yet finished. Will be set to `false` before emitting `connect` event
and/or calling [`socket.connect(options[, connectListener])`][`socket.connect(options, connectListener)`]'s callback.

### socket.destroy()
### socket.destroy([exception])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two bits:

  1. What is the expected type of the argument
  2. Either reason or error would be better than exception

Copy link
Member Author

@Trott Trott Jun 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasnell I chose exception because that's what it is called in the code. If we want to change it, do we have to reach into the code to change it there too?

I don't like error for the document because then you have to explain that error will be passed as an argument to any listeners on the 'error' event, which can get confusing especially to new users. So I'd probably go with reason over error, but reason doesn't signal to the reader that it's an error the way exception does.

As for the type, it would seem to be expecting an Error object but it actually doesn't look like there's any enforcement in the code so you could probably send it anything at all. I mean, it's just an argument for a listener, so it's kinda sorta up to the end user, I suppose. Suggest that it should (rather than must) be an Error perhaps?

<!-- YAML
added: v0.1.90
-->

Ensures that no more I/O activity happens on this socket. Only necessary in
case of errors (parse error or so).

If `exception` is specified, an [`'error'`][] event will be emitted and any
listeners for that event will receive `exception` as an argument.

### socket.destroyed

A Boolean value that indicates if the connection is destroyed or not. Once a
Expand Down