Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: runtime/observatory/lib/src/service/object.dart

Issue 2343183002: Fix service test websocket error edge case (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/observatory/tests/service/test_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/service/object.dart
diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart
index 6ead6a02c036d87bf655a367de90f95ebd44d53b..51ac8eb94e45e827c014551424839fb8c99aad80 100644
--- a/runtime/observatory/lib/src/service/object.dart
+++ b/runtime/observatory/lib/src/service/object.dart
@@ -77,6 +77,14 @@ class NetworkRpcException extends RpcException
String toString() => 'NetworkRpcException(${message})';
}
+Future<ServiceObject> ignoreNetworkErrors(
+ Object error, [ServiceObject resultOnNetworkError = null]) {
+ if (error is NetworkRpcException) {
+ return new Future.value(resultOnNetworkError);
+ }
+ return new Future.error(error);
+}
+
class MalformedResponseRpcException extends RpcException {
MalformedResponseRpcException(String message, this.response) : super(message);
@@ -400,7 +408,9 @@ abstract class HeapObject extends ServiceObject implements M.Object {
// Load the full class object if the isolate is runnable.
if (clazz != null) {
if (clazz.isolate.runnable) {
- clazz.load();
+ // No one awaits on this request so we silence any network errors
+ // that occur here but forward other errors.
+ clazz.load().catchError((error) => ignoreNetworkErrors(error, clazz));
}
}
@@ -860,24 +870,18 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
Map params = {
'streamId': streamId,
};
- return invokeRpc('streamListen', params).catchError((e) {
- // Ignore network errors on stream listen.
- if (e is NetworkRpcException) {
- return null;
- }
- });
+ // Ignore network errors on stream listen.
+ return invokeRpc('streamListen', params).catchError(
+ (e) => ignoreNetworkErrors(e));
}
Future<ServiceObject> _streamCancel(String streamId) {
Map params = {
'streamId': streamId,
};
- return invokeRpc('streamCancel', params).catchError((e) {
- // Ignore network errors on stream cancel.
- if (e is NetworkRpcException) {
- return null;
- }
- });
+ // Ignore network errors on stream cancel.
+ return invokeRpc('streamCancel', params).catchError(
+ (e) => ignoreNetworkErrors(e));
}
// A map from stream id to event stream state.
« no previous file with comments | « no previous file | runtime/observatory/tests/service/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698