tools
tools copied to clipboard
unified analytics crashes when SocketException in GAClient.sendData
Sometimes when running dart pub get, I get this crash:
build-collection-1.18.0: SocketException: Connection failed (OS Error: No route to host, errno = 65), address = www.google-analytics.com, port = 443
build-collection-1.18.0: #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:721:35)
build-collection-1.18.0: #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1914:26)
build-collection-1.18.0: #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
build-collection-1.18.0: #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:299:22)
build-collection-1.18.0: #4 SecureSocket.startConnect (dart:io/secure_socket.dart:77:28)
build-collection-1.18.0: #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2483:26)
build-collection-1.18.0: #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2926:12)
build-collection-1.18.0: #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2931:12)
build-collection-1.18.0: #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2786:12)
build-collection-1.18.0: #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2623:7)
build-collection-1.18.0: #10 IOClient.send (package:http/src/io_client.dart:88:38)
build-collection-1.18.0: #11 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:38)
build-collection-1.18.0: #12 BaseClient.post (package:http/src/base_client.dart:32:7)
build-collection-1.18.0: #13 GAClient.sendData (package:unified_analytics/src/ga_client.dart:66:28)
build-collection-1.18.0: #14 AnalyticsImpl.send (package:unified_analytics/src/analytics.dart:610:38)
build-collection-1.18.0: #15 DartdevRunner.runCommand (package:dartdev/dartdev.dart:255:26)
build-collection-1.18.0: <asynchronous suspension>
build-collection-1.18.0: #16 runDartdev (package:dartdev/dartdev.dart:57:16)
build-collection-1.18.0: <asynchronous suspension>
build-collection-1.18.0: #17 main (file:///Volumes/Work/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:3)
build-collection-1.18.0: <asynchronous suspension>.
Unhandled exception:
SubprocessException[command: "dart pub get", workingDirectory: "/var/folders/gd/9q4y0d095wq9mgmq1wtx8w_w005w15/T/collectionIFMRHi", exitCode: 255]
The prefix, build-collection-1.18.0 and the last line, are logging from dartdoc.
I imagine dartdev could try to catch this exception, but maybe unified_analytics should be catching it? If the former, let me know and I can move this bug over to dartdev.
@srawlins thank you for bringing this up! Do you have any simple reproducible steps for this?
Although I am curious as to why this not already being caught by the package, we already have a catch around the IOClient.post...?
https://github.com/dart-lang/tools/blob/main/pkgs/unified_analytics/lib/src/ga_client.dart#L65-L85
We just saw another instance of this:
WARNING: 2024-04-09 19:12:44.357621: Unhandled exception:
SocketException: Connection failed (OS Error: No route to host, errno = 65), address = [www.google-analytics.com](http://www.google-analytics.com/), port = 443
#0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:721:35)
#1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1914:26)
#2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
#3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:299:22)
#4 SecureSocket.startConnect (dart:io/secure_socket.dart:77:28)
#5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2483:26)
#6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2926:12)
#7 _HttpClient._getConnection (dart:_http/http_impl.dart:2931:12)
#8 _HttpClient._openUrl (dart:_http/http_impl.dart:2786:12)
#9 _HttpClient.openUrl (dart:_http/http_impl.dart:2623:7)
#10 IOClient.send (package:http/src/io_client.dart:88:38)
#11 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:38)
#12 BaseClient.post (package:http/src/base_client.dart:32:7)
#13 GAClient.sendData (package:unified_analytics/src/ga_client.dart:66:28)
#14 AnalyticsImpl.send (package:unified_analytics/src/analytics.dart:610:38)
#15 DartdevRunner.runCommand (package:dartdev/dartdev.dart:255:26)
<asynchronous suspension>
#16 runDartdev (package:dartdev/dartdev.dart:57:16)
<asynchronous suspension>
#17 main (file:///Volumes/Work/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:3)
<asynchronous suspension>.
SEVERE: 2024-04-09 19:12:44.368987: 'dart pub get' failed
@eliasyishak, yeah, I don't see how this can happen.
It might be possible to reproduce locally by hacking /etc/hosts such that www.google-analytics.com points to an IP that is unreachable.
But I would imagine the exception gets caught:)
@srawlins thank you for bringing this up! Do you have any simple reproducible steps for this?
Sorry for not responding! I didn't have good steps, and dart pub get was launched by another script, so it wasn't something I was super in control of (like, not easily re-run with different flags or under different conditions; kind of a pain to reproduce). I was hoping that with the stack trace it might be apparent how it could happen. I will try to get more details if I see it again.
No problem, I spent a couple days looking into this earlier when you first posted and i have been struggling to reproduce the error, every time i was able to get a SocketException thrown, it was caught by the try/catch and silently fails, doesn't end up crashing the tool using this package.