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:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value #54

Closed
niluved opened this issue May 27, 2023 · 2 comments

Comments

@niluved
Copy link

niluved commented May 27, 2023

Hi there!
Just upgraded my project to Flutter 3.10.2 / Dart 3.0.2 and i fear something is broken now.
I have dart_openai: ^1.9.93 and http: ^0.13.6 in my pubspec.yaml (nothing changes even reverting to some minor versions such as dart_openai 1.9.91 or http 0.13.5 which were working great before my flutter upgrade).

My android app listens to a Stream to update a list of strings and return some info on the screen but now, when the stream response is done, nothing is displayed and i get the following lines in the console:

[OpenAI] stream response is done
E/flutter (11371): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter (11371): #0 OpenAINetworkingClient.postStream.close
client.dart:264
E/flutter (11371): #1 OpenAINetworkingClient.postStream..
client.dart:317
E/flutter (11371): #2 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
E/flutter (11371): #3 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
E/flutter (11371): #4 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
E/flutter (11371): #5 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
E/flutter (11371): #6 _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
E/flutter (11371): #7 _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
E/flutter (11371): #8 _StringAdapterSink.close (dart:convert/string_conversion.dart:241:11)
E/flutter (11371): #9 _LineSplitterSink.close (dart:convert/line_splitter.dart:141:11)
E/flutter (11371): #10 _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
E/flutter (11371): #11 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
E/flutter (11371): #12 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
E/flutter (11371): #13 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
E/flutter (11371): #14 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
E/flutter (11371): #15 _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
E/flutter (11371): #16 _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
E/flutter (11371): #17 _StringAdapterSink.close (dart:convert/string_conversion.dart:241:11)
E/flutter (11371): #18 _Utf8ConversionSink.close (dart:convert/string_conversion.dart:295:20)
E/flutter (11371): #19 _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:78:18)
E/flutter (11371): #20 _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
E/flutter (11371): #21 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
E/flutter (11371): #22 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
E/flutter (11371): #23 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
E/flutter (11371): #24 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
E/flutter (11371): #25 _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
E/flutter (11371): #26 _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
E/flutter (11371): #27 _HttpClientResponse.listen. (dart:_http/http_impl.dart:726:15)
E/flutter (11371): #28 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
E/flutter (11371): #29 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
E/flutter (11371): #30 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
E/flutter (11371): #31 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
E/flutter (11371): #32 _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
E/flutter (11371): #33 _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
E/flutter (11371): #34 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
E/flutter (11371): #35 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
E/flutter (11371): #36 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
E/flutter (11371): #37 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
E/flutter (11371): #38 _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:784:19)
E/flutter (11371): #39 _StreamController._closeUnchecked (dart:async/stream_controller.dart:639:7)
E/flutter (11371): #40 _StreamController.close (dart:async/stream_controller.dart:632:5)
E/flutter (11371): #41 _HttpParser._closeIncoming (dart:_http/http_parser.dart:1147:18)
E/flutter (11371): #42 _HttpParser._doParse (dart:_http/http_parser.dart:813:11)
E/flutter (11371): #43 _HttpParser._parse (dart:_http/http_parser.dart:319:7)
E/flutter (11371): #44 _HttpParser._onData (dart:_http/http_parser.dart:873:5)
E/flutter (11371): #45 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (11371): #46 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (11371): #47 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (11371): #48 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
E/flutter (11371): #49 _StreamController._add (dart:async/stream_controller.dart:650:7)
E/flutter (11371): #50 _StreamController.add (dart:async/stream_controller.dart:598:5)
E/flutter (11371): #51 _Socket._onData (dart:io-patch/socket_patch.dart:2368:41)
E/flutter (11371): #52 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (11371): #53 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (11371): #54 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (11371): #55 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
E/flutter (11371): #56 _StreamController._add (dart:async/stream_controller.dart:650:7)
E/flutter (11371): #57 _StreamController.add (dart:async/stream_controller.dart:598:5)
E/flutter (11371): #58 _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1114:19)
E/flutter (11371): #59 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
E/flutter (11371): #60 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (11371): #61 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (11371): #62 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
E/flutter (11371):

i guess the app gets stuck in client.dart at the lines 264 and 317, but i don't want to mess up with that file.
what can i do?

thanks

@mengcodecn
Copy link

There is the same problem

@anasfik
Copy link
Owner

anasfik commented May 29, 2023

Hello, Thank you for reaching here about that issue.

And yes, it was an issue with the add of custom HTTP client property to the package methods which results in to immediate call of close() if that client is null.

Please, I did fix all of that in version 2.0.0, it passes all tests and so you should have it working just fine as you expect now!

@anasfik anasfik closed this as completed May 29, 2023
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

3 participants