Handle notification errors (#31868)

This commit is contained in:
Dan Field
2019-04-30 15:42:22 -07:00
committed by GitHub
parent 5e77d6508e
commit c0d5fd23ab
3 changed files with 29 additions and 2 deletions

View File

@@ -934,9 +934,18 @@ void restoreVmServiceConnectFunction() {
}
void _unhandledJsonRpcError(dynamic error, dynamic stack) {
if (error is rpc.RpcException) {
final rpc.RpcException rpcException = error;
if (rpcException.data != null && rpcException.data['id'] == null) {
// This can happen, e.g., if a client tries to call us before methods have
// been registered, but the client doesn't care for a response.
_log.trace('RPC client sent a notification that resulted in an error:\n$error');
return;
}
assert(false, 'json_rpc_2 failed to send an exception back to the client.');
}
_log.trace('Unhandled RPC error:\n$error\n$stack');
// TODO(dnfield): https://github.com/flutter/flutter/issues/31813
// assert(false);
assert(false);
}
/// Waits for a real Dart VM service to become available, then connects using