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

FormatException if EventSource does not contain valid utf8 #22

Open
neokree opened this issue Sep 22, 2021 · 1 comment · May be fixed by #23
Open

FormatException if EventSource does not contain valid utf8 #22

neokree opened this issue Sep 22, 2021 · 1 comment · May be fixed by #23

Comments

@neokree
Copy link

neokree commented Sep 22, 2021

Hello,

I have an external API that is returning me an EventStream with a JSON content, but it seems like they are returning an invalid utf8, since when connecting to it I have this error the majority of events.

Unhandled Exception: FormatException: Missing extension byte (at offset 7291)
E/flutter (12039): #0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1887:7)
E/flutter (12039): #1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:314:28)
E/flutter (12039): #2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:310:5)
E/flutter (12039): #3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:72:18)
E/flutter (12039): #4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:121:24)
E/flutter (12039): #5      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (12039): #6      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (12039): #7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (12039): #8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (12039): #9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (12039): #10     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:127:11)
E/flutter (12039): #11     _HandleErrorStream._handleData (dart:async/stream_pipe.dart:266:10)
E/flutter (12039): #12     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:157:13)
E/flutter (12039): #13     _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (12039): #14     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (12039): #15     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (12039): #16     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (12039): #17     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (12039): #18     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:127:11)
E/flutter (12039): #19     _HandleErrorStream._handleData (dart:async/stream_pipe.dart:266:10)
E/flutter (12039): #20     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:157:13)
E/flutter (12039): #21     _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (12039): #22     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (12039): #23     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (12039): #24     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (12039): #25     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (12039): #26     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
E/flutter (12039): #27     _StreamController._add (dart:async/stream_controller.dart:682:7)
E/flutter (12039): #28     _StreamController.add (dart:async/stream_controller.dart:624:5)
E/flutter (12039): #29     _HttpParser._doParse (dart:_http/http_parser.dart:809:28)
E/flutter (12039): #30     _HttpParser._parse (dart:_http/http_parser.dart:324:7)
E/flutter (12039): #31     _HttpParser._onData (dart:_http/http_parser.dart:853:5)
E/flutter (12039): #32     _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (12039): #33     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (12039): #34     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (12039): #35     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (12039): #36     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (12039): #37     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
E/flutter (12039): #38     _StreamController._add (dart:async/stream_controller.dart:682:7)
E/flutter (12039): #39     _StreamController.add (dart:async/stream_controller.dart:624:5)
E/flutter (12039): #40     _Socket._onData (dart:io-patch/socket_patch.dart:2044:41)
E/flutter (12039): #41     _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (12039): #42     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (12039): #43     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (12039): #44     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (12039): #45     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (12039): #46     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
E/flutter (12039): #47     _StreamController._add (dart:async/stream_controller.dart:682:7)
E/flutter (12039): #48     _StreamController.add (dart:async/stream_controller.dart:624:5)
E/flutter (12039): #49     _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1002:19)
E/flutter (12039): #50     _rootRun (dart:async/zone.dart:1182:47)
E/flutter (12039): #51     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (12039): #52     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (12039): #53     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter (12039): #54     _rootRun (dart

It would be great if there could be a way to allow invalid UTF8 characters in the Event.data.

@stevenroose
Copy link
Owner

Is there more demand than just you for non-utf8 streams? UTF8 is the recommended encoding for JSON.

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

Successfully merging a pull request may close this issue.

2 participants