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

Make error parameter of stream.abort optional #2716

Closed
mkermani144 opened this issue Sep 24, 2024 · 2 comments
Closed

Make error parameter of stream.abort optional #2716

mkermani144 opened this issue Sep 24, 2024 · 2 comments

Comments

@mkermani144
Copy link

*
* The sink will return and the source will throw if an error is passed or return normally if not.
*/
abort(err: Error): void

It's stated that source will throw if error is passed, and will return otherwise. But the parameter is not optional, and it's not possible not to pass an error to abort.

@achingbrain
Copy link
Member

That's a mistake in the docs. If you want to close a connection gracefully (e.g. wait for all data to be sent), call conn.close(), if you want to close immediately, call conn.abort(err) and pass the reason.

In the future that error will get turned into an error code and sent to the remote peer so they know what went wrong.

@mkermani144
Copy link
Author

Cool, maybe we can fix the doc in the future.

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

No branches or pull requests

2 participants