Ignore some JSON RPC errors (#32710)
This commit is contained in:
@@ -956,7 +956,35 @@ void restoreVmServiceConnectFunction() {
|
||||
vmServiceConnectFunction = _waitAndConnect;
|
||||
}
|
||||
|
||||
/// The JSON RPC 2 spec says that a notification from a client must not respond
|
||||
/// to the client. It's possible the client sent a notification as a "ping", but
|
||||
/// the service isn't set up yet to respond.
|
||||
///
|
||||
/// For example, if the client sends a notification message to the server for
|
||||
/// 'streamNotify', but the server has not finished loading, it will throw an
|
||||
/// exception. Since the message is a notification, the server follows the
|
||||
/// specification and does not send a response back, but is left with an
|
||||
/// unhandled exception. That exception is safe for us to ignore - the client
|
||||
/// is signaling that it will try again later if it doesn't get what it wants
|
||||
/// here by sending a notification.
|
||||
// This may be ignoring too many exceptions. It would be best to rewrite
|
||||
// the client code to not use notifications so that it gets error replies back
|
||||
// and can decide what to do from there.
|
||||
// TODO(dnfield): https://github.com/flutter/flutter/issues/31813
|
||||
bool _ignoreRpcError(dynamic error) {
|
||||
if (error is rpc.RpcException) {
|
||||
final rpc.RpcException exception = error;
|
||||
return exception.data == null || exception.data['id'] == null;
|
||||
} else if (error is String && error.startsWith('JSON-RPC error -32601')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void _unhandledJsonRpcError(dynamic error, dynamic stack) {
|
||||
if (_ignoreRpcError(error)) {
|
||||
return;
|
||||
}
|
||||
_log.trace('Unhandled RPC error:\n$error\n$stack');
|
||||
// TODO(dnfield): https://github.com/flutter/flutter/issues/31813
|
||||
// assert(false);
|
||||
|
||||
@@ -31,8 +31,36 @@ typedef RpcPeerConnectionFunction = Future<json_rpc.Peer> Function(
|
||||
/// custom connection function is needed.
|
||||
RpcPeerConnectionFunction fuchsiaVmServiceConnectionFunction = _waitAndConnect;
|
||||
|
||||
/// The JSON RPC 2 spec says that a notification from a client must not respond
|
||||
/// to the client. It's possible the client sent a notification as a "ping", but
|
||||
/// the service isn't set up yet to respond.
|
||||
///
|
||||
/// For example, if the client sends a notification message to the server for
|
||||
/// 'streamNotify', but the server has not finished loading, it will throw an
|
||||
/// exception. Since the message is a notification, the server follows the
|
||||
/// specification and does not send a response back, but is left with an
|
||||
/// unhandled exception. That exception is safe for us to ignore - the client
|
||||
/// is signaling that it will try again later if it doesn't get what it wants
|
||||
/// here by sending a notification.
|
||||
// This may be ignoring too many exceptions. It would be best to rewrite
|
||||
// the client code to not use notifications so that it gets error replies back
|
||||
// and can decide what to do from there.
|
||||
// TODO(dnfield): https://github.com/flutter/flutter/issues/31813
|
||||
bool _ignoreRpcError(dynamic error) {
|
||||
if (error is json_rpc.RpcException) {
|
||||
final json_rpc.RpcException exception = error;
|
||||
return exception.data == null || exception.data['id'] == null;
|
||||
} else if (error is String && error.startsWith('JSON-RPC error -32601')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void _unhandledJsonRpcError(dynamic error, dynamic stack) {
|
||||
if (_ignoreRpcError(error)) {
|
||||
return;
|
||||
}
|
||||
_log.fine('Error in internalimplementation of JSON RPC.\n$error\n$stack');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user