Skip to content

Errors are ignored in broadcast StreamController without listeners #29403

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

Closed
alsemenov opened this issue Apr 20, 2017 · 4 comments
Closed

Errors are ignored in broadcast StreamController without listeners #29403

alsemenov opened this issue Apr 20, 2017 · 4 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-a library-async type-documentation A request to add or improve documentation

Comments

@alsemenov
Copy link
Contributor

The description for constructor StreamController.broadcast() reads:

StreamController.broadcast({
void onListen(),
void onCancel(),
bool sync: false
})
A controller where stream can be listened to more than once.
...
The controller does not have any internal queue of events, and if there are no listeners at the time the event is added, it will just be dropped, or, if it is an error, be reported as uncaught.

The following sample code shows that errors are just ignored:

import "dart:async";

main() {
  StreamController controller = new StreamController.broadcast();
  try {
    controller.addError("lost error");
    print("'lost error' is ignored");
  } catch (e) {
    print("caught $e");
  }
}

Output:

'lost error' is ignored

Expected output:

caught 'lost error'

Dart VM version: 1.22.1 (Tue Feb 21 14:29:45 2017) on "windows_x64"

@anders-sandholm anders-sandholm added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-async labels Apr 24, 2017
@anders-sandholm
Copy link
Contributor

Unclear to me if this is a VM or async issue. Re-label as you see fit.

@lrhn
Copy link
Member

lrhn commented Sep 29, 2020

Still appears to be the case. Not sure if we really want to make the error into an async uncaught error now, but we should document that it isn't.

The code above doesn't check for uncaught async errors, but it's also not reported by:

import "dart:async";

main() {
  runZoned(() {
    StreamController controller = StreamController.broadcast();
    controller.addError("lost error");
    Future.error("found error");
  }, onError: print);
}

@lrhn lrhn added type-documentation A request to add or improve documentation and removed area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Sep 29, 2020
@sgrekhov
Copy link
Contributor

https://dart-review.googlesource.com/c/sdk/+/340860 updates the documentation

copybara-service bot pushed a commit that referenced this issue Dec 12, 2023
…current behavior

Bug: #29403
Change-Id: I9ef53b3c4e039bdc84d4cdfa9e306efb6eb0ffba
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340860
Reviewed-by: Lasse Nielsen <[email protected]>
Reviewed-by: Alexander Thomas <[email protected]>
Commit-Queue: Alexander Thomas <[email protected]>
@sgrekhov
Copy link
Contributor

Documentation has been updated. The current behavior is according to the spec now. Closing this issue

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. core-a library-async type-documentation A request to add or improve documentation
Projects
None yet
Development

No branches or pull requests

5 participants