From 806b1a962e73e9d685515b3dfe6453815399874f Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Mon, 21 Oct 2024 13:29:00 -0700 Subject: [PATCH] Make sure to not proxy to RPC when already handled request --- json-rpc.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/json-rpc.js b/json-rpc.js index 921c89a..e02e84e 100644 --- a/json-rpc.js +++ b/json-rpc.js @@ -246,7 +246,7 @@ const handleJsonRpc = async ctx => { ctx.body = rpcResult(body.id, await handleQuery({ blockHeight, body })); } - break; + return; } case 'chunk': { const { block_id, shard_id } = body.params; @@ -268,23 +268,23 @@ const handleJsonRpc = async ctx => { throw new FastNEARError('chunkNotFound', `Chunk not found: ${block_id} ${shard_id}`, { block_id, shard_id }); } - break; + return; } case 'broadcast_tx_commit': { const result = await submitTransaction(Buffer.from(body.params[0], 'base64')); ctx.body = rpcResult(body.id, result); - break; + return; } default: // Fall back to proxying - break; + await proxyJson(ctx); } } catch (error) { await handleError({ ctx, blockHeight: null, error }); return; } - await proxyJson(ctx); + throw new Error('Should not happen'); }; async function handleQuery({ blockHeight, body }) {