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

Error Handler Not Being Called #77

Open
cycloss opened this issue Jan 13, 2022 · 0 comments
Open

Error Handler Not Being Called #77

cycloss opened this issue Jan 13, 2022 · 0 comments

Comments

@cycloss
Copy link

cycloss commented Jan 13, 2022

I've come up with a minimum viable example that shows my problem below. For some reason, print('Error occured: $e'); is never called. Instead I get Unhandled Exception: Exception. I can't understand why the error handler on the channel in the main function isn't picking up this error. Is this a bug?

import 'dart:isolate';

import 'package:stream_channel/isolate_channel.dart';

void main() async {
  var rp = ReceivePort();
  var channel = IsolateChannel.connectReceive(rp);
  channel.stream.listen(print);
  channel.stream.handleError((e) {
    print('Error occured: $e');
  });
  await Isolate.spawn(task, rp.sendPort);
}

void task(SendPort sp) {
  var channel = IsolateChannel.connectSend(sp);
  channel.sink.add('Hello');
  channel.sink.addError(Exception());
}
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

1 participant