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

Socket.addError not supported #60400

Closed
jakobleck opened this issue Mar 25, 2025 · 3 comments
Closed

Socket.addError not supported #60400

jakobleck opened this issue Mar 25, 2025 · 3 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io triaged Issue has been triaged by sub team type-documentation A request to add or improve documentation

Comments

@jakobleck
Copy link

jakobleck commented Mar 25, 2025

The following minimal code example demonstrates that apparently you cannot use Socket.addError: It throws Unsupported operation: Cannot send errors on sockets. (run with dart 3.5.3 on a mac)

import 'dart:io';

void main() async {
  int port = 33333;
  ServerSocket serverSocket = await ServerSocket.bind(InternetAddress.anyIPv6, port);
  serverSocket.listen((socket) async {
    socket.addError("error");
  });
  await Socket.connect("127.0.0.1", port);
  await Future.delayed(Duration(seconds: 1));
}

Is this a bug, and if not, should this be documented in the documentation? (Edit: Ok, I realized that Socket is abstract, so maybe it makes no sense to describe implementation details in its doc...) There addError just redirects to the doc of IOSink, from which the method was inherited.

@ykmnkmi
Copy link
Contributor

ykmnkmi commented Mar 25, 2025

/// Unsupported operation on sockets.
///
/// Throws an [UnsupportedError] because errors cannot be transmitted over a
/// [Socket].

addError is documented in the internal implementation, but not in the public API.

@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io type-documentation A request to add or improve documentation labels Mar 25, 2025
@jakobleck
Copy link
Author

Thanks, that clears it up for me.

@a-siva a-siva added the triaged Issue has been triaged by sub team label Mar 26, 2025
@a-siva a-siva self-assigned this Mar 26, 2025
@lrhn lrhn closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2025
@lrhn lrhn reopened this Mar 27, 2025
@a-siva
Copy link
Contributor

a-siva commented Mar 27, 2025

https://dart-review.googlesource.com/c/sdk/+/417909 should surface the error to the public API

@a-siva a-siva closed this as completed Mar 27, 2025
copybara-service bot pushed a commit that referenced this issue Mar 27, 2025
(Moved the documentation to the public interface so it is visible in the
API documentation, please see
#60400)

TEST=ci

Change-Id:I1a0bb354b45b2b89852c04a0f16e5b9060e4a9b6
CoreLibraryReviewExempt:"Changes in comments to Socket class
which other libraries do not use"
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417909
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io triaged Issue has been triaged by sub team type-documentation A request to add or improve documentation
Projects
None yet
Development

No branches or pull requests

4 participants