From 2a82724fa0a2c0a8e55ce60d908871ca04ec10eb Mon Sep 17 00:00:00 2001 From: Toma Morris Date: Mon, 9 Sep 2019 10:05:19 -0400 Subject: [PATCH] fix(api): remove protocol file size limit and ack immediately (#4006) * fix(api): remove protocol file size limit and ack immediately. Fixes #3998 --- api/src/opentrons/server/rpc.py | 18 ++++-------------- api/tests/opentrons/server/test_server.py | 5 +++++ app/src/robot/api-client/index.js | 2 +- app/src/rpc/client.js | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/api/src/opentrons/server/rpc.py b/api/src/opentrons/server/rpc.py index 3db489a3ce0..6dde77f72ef 100755 --- a/api/src/opentrons/server/rpc.py +++ b/api/src/opentrons/server/rpc.py @@ -84,13 +84,9 @@ def send_worker(self, socket): def task_done(future): try: - result = future.result() + future.result() except Exception: log.exception("send_task for socket {} threw:".format(_id)) - else: - log.info('send_task for socket {} result: {}'.format( - _id, result)) - log.debug('Send task for {} finished'.format(_id)) async def send_task(socket, queue): while True: @@ -140,24 +136,20 @@ def task_done(future): traceback.format_exc()) ) - client = web.WebSocketResponse() + client = web.WebSocketResponse(max_msg_size=0) client_id = id(client) # upgrade to Websockets await client.prepare(request) log.info('Opening Websocket {0}'.format(id(client))) - log.debug('Tasks: {0}'.format(self.tasks)) - log.debug('Clients: {0}'.format(self.clients)) try: - log.debug('Sending root info to {0}'.format(client_id)) await client.send_json({ '$': {'type': CONTROL_MESSAGE, 'monitor': True}, 'root': self.call_and_serialize(lambda: self.root), 'type': self.call_and_serialize(lambda: type(self.root)) }) - log.debug('Root info sent to {0}'.format(client_id)) except Exception: log.exception('While sending root info to {0}'.format(client_id)) @@ -241,11 +233,11 @@ async def process(self, message): _id = id(self.system) try: + self.send_ack(token) func = self.build_call( _id=_id, name=data.get('name'), args=data.get('args', [])) - self.send_ack(token) except Exception as e: log.exception("Exception during rpc.Server.process:") error = '{0}: {1}'.format(e.__class__.__name__, e) @@ -258,7 +250,7 @@ async def process(self, message): 'WebSocket connection closed unexpectedly: {0}'.format( message)) else: - log.warning('Unhanled WSMsgType: {0}'.format(message.type)) + log.warning('Unhandled WSMsgType: {0}'.format(message.type)) except Exception: log.exception('Error while processing request') @@ -274,7 +266,6 @@ def call_and_serialize(self, func, max_depth=0): async def make_call(self, func, token): response = {'$': {'type': CALL_RESULT_MESSAGE, 'token': token}} try: - log.info(f"RPC call: {func} begins") call_result = await self.loop.run_in_executor( self.executor, self.call_and_serialize, func) response['$']['status'] = 'success' @@ -306,7 +297,6 @@ async def make_call(self, func, token): 'traceback': trace } finally: - log.info(f"RPC call: {func} ends") response['data'] = call_result return response diff --git a/api/tests/opentrons/server/test_server.py b/api/tests/opentrons/server/test_server.py index 1ee78a75eaa..c1dd95490f8 100755 --- a/api/tests/opentrons/server/test_server.py +++ b/api/tests/opentrons/server/test_server.py @@ -121,6 +121,11 @@ async def test_exception_during_call(session): await session.socket.receive_json() await session.call() res = await session.socket.receive_json() + assert res.pop('$') == { + 'type': rpc.CALL_ACK_MESSAGE, + 'token': session.token + } + res = await session.socket.receive_json() assert res.pop('$') == { 'type': rpc.CALL_NACK_MESSAGE, 'token': session.token diff --git a/app/src/robot/api-client/index.js b/app/src/robot/api-client/index.js index b6bdebed37a..26f0967a5b4 100644 --- a/app/src/robot/api-client/index.js +++ b/app/src/robot/api-client/index.js @@ -23,7 +23,7 @@ export default function apiClientMiddleware() { action.error === true ? action.payload : action.payload.error if (error) { - log.warn('Error response from robot', { action }) + log.warn('Error response from robot', { actionType: action.type }) if (error.traceback) log.warn(error.traceback) } } diff --git a/app/src/rpc/client.js b/app/src/rpc/client.js index 359b15f702e..a49fb4445bc 100644 --- a/app/src/rpc/client.js +++ b/app/src/rpc/client.js @@ -156,7 +156,7 @@ class RpcContext extends EventEmitter { } // cache required metadata from call results - // filter type field from type object to avoid getting unecessary types + // filter type field from type object to avoid getting unnecessary types _cacheCallResultMetadata(resultData) { if (!resultData || !resultData.i) { return