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

Improve error messages for incorrect use of socket interface #2291

Closed
DartBot opened this issue Mar 24, 2012 · 6 comments
Closed

Improve error messages for incorrect use of socket interface #2291

DartBot opened this issue Mar 24, 2012 · 6 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-io type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Mar 24, 2012

This issue was originally filed by @financecoding


What steps will reproduce the problem?

  1. The following url tells more about the bug https://gist.github.com/2188456
  2. git clone git://gist.github.com/2188456.git
  3. cd 2188456
  4. dart socketTest.dart

What is the expected output? What do you see instead?
Exceptions being thrown cause _SocketBase._id is -1. In earlier sdk this did not happen, _id would be set to 0 if the socket was created successfully.

What version of the product are you using? On what operating system?
Information provided in the gist

Please provide any additional information below.
Dart Rocks!

@sgjesse
Copy link
Contributor

sgjesse commented Mar 26, 2012

There have been recent changes to make the actual connecting of the socket asynchronous. That is the actual connetion will not be present until the onConnect callback is called. Likewise errors are handled using the onError callback which should now provide an Exception object with information on the actual error.

The motivation for this is:

  1. DNS lookup can taks several hundred milliseconds, and we don't want to block in the IO code
  2. Be consistent with the asynchronous programming model

Try to rewrite the code to:

main() {
  Socket s = new Socket("127.0.0.1", 8888);
  s.onError = (e) => print("Error: $e");
  s.onConnect = () {
    print('s = ${s.available()}');
    s.close();
  }
}

The SocketIOException thrown has the message "SocketIOException: Error: available failed - invalid socket handle". That is not very informative. Something like "SocketIOException: Error: available failed - socket connection pending". To handle this a socket should have a state CONNECTING, CONNECTED, CLOSED_READ, CLOSED_WRITE, CLOSED.


Set owner to @sgjesse.
Removed Type-Defect label.
Added Type-Enhancement, Area-IO, Accepted labels.

@madsager
Copy link
Contributor

Changed the title to: "Improve error messages for incorrect use of socket interface".

@madsager
Copy link
Contributor

madsager commented Jun 7, 2012

Added this to the M1 milestone.

@madsager
Copy link
Contributor

madsager commented Sep 4, 2012

Removed this from the M1 milestone.

@sgjesse
Copy link
Contributor

sgjesse commented Feb 27, 2013

Added AssumedStale label.

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Area-Library, Library-IO labels.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io closed-obsolete Closed as the reported issue is no longer relevant labels May 14, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
dart-bot pushed a commit that referenced this issue Jan 16, 2020
New commits included in this revision:
```
$ git log --pretty=oneline 4d8ecbd409d773fec47da33b7e6c8db0b51487fd..429a06039d185149f387a65e3503b0693ce6d24e
429a06039d185149f387a65e3503b0693ce6d24e (HEAD -> master, origin/master, origin/HEAD) Parallel fetching of available versions (#2280)
6705b085b9bf4754a4c8002a070f436f115dc4d1 Retry on all SocketExceptions (#2254)
a1820273b9f3c7bb5a13d26cd14d30d5bab187ae Use a unqiue file name for the snapshot during testing. (#2303)
72686563e767f8a359e48a267a2c323953a6a0ef Include osx and windows testing on Travis (#2299)
a7a66821d13920b9b22cc394dfa55c679e971e40 Fail travis for lints and warnings (#2301)
25aa24c023453f064dad8f3cce1bbd55269d0efa Omit languageVersion when there is no SDK constraint (#2300)
82e60a3dcb3afe753563e7d304827fb650bc4833 Use LOCALAPPDATA for system cache on windows (#2297)
ceaa86f2c7eb35f044b4c202268a17361de68d13 Enforce and fix lints from package:pedantic (#2291)
6ce1606564352c305bd0f6d97704f0f7f6ebbca0 Use more collection literals for args (#2293)
be245e6baeebb71aaf3b3a260fcfbbb011a9a7e0 Rename some test utilities from Mock to Fake (#2294)
f7638ce85298df7d9e73d717dd4d81f499681720 Refactor Set.add following !Set.contains (#2295)
390022b24bc076cb934385936ac7904f045a75ba Filter out `null` from `getCachedPackages`. (#2292)
0eea0c4421ed0b83c8597b62dacf68b93de172b9 Fix existing hints and lints (#2290)
7cf2fe860a40517ccb65f5efdda9e4dc350142c3 promote strict deps failures to errors from warnings (#2289)
```

Change-Id: I62782b29e16092114940df00811bfdd20c8045fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131839
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-io type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants