From 0a088e5f565fff3e71c355384bc613d3d0e8d3aa Mon Sep 17 00:00:00 2001 From: Will Meister Date: Wed, 29 Apr 2020 11:09:43 -0500 Subject: [PATCH 1/3] fixing issue logging FormattedJsonRpcErrorResponse as error --- .../rollup-full-node/src/app/routing-handler.ts | 16 +++++++++------- .../test/app/routing-handler.spec.ts | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/rollup-full-node/src/app/routing-handler.ts b/packages/rollup-full-node/src/app/routing-handler.ts index f7368ef122a5..45860235d5b3 100644 --- a/packages/rollup-full-node/src/app/routing-handler.ts +++ b/packages/rollup-full-node/src/app/routing-handler.ts @@ -117,13 +117,15 @@ export class RoutingHandler implements FullnodeHandler { } return result.result } catch (e) { - logError( - log, - `Error proxying request: [${method}], params: [${JSON.stringify( - params - )}]`, - e - ) + if (!(e instanceof FormattedJsonRpcError)) { + logError( + log, + `Error proxying request: [${method}], params: [${JSON.stringify( + params + )}]`, + e + ) + } throw e } } diff --git a/packages/rollup-full-node/test/app/routing-handler.spec.ts b/packages/rollup-full-node/test/app/routing-handler.spec.ts index 7403fd27693a..9392d4670432 100644 --- a/packages/rollup-full-node/test/app/routing-handler.spec.ts +++ b/packages/rollup-full-node/test/app/routing-handler.spec.ts @@ -314,7 +314,7 @@ describe('Routing Handler', () => { error.should.be.instanceOf(FormattedJsonRpcError, 'Invalid error type!') const formatted: FormattedJsonRpcError = error as FormattedJsonRpcError formatted.jsonRpcResponse.should.deep.equal( - transactionErrorResponsePayload, + transactionErrorRFesponsePayload, 'Incorrect error returned!' ) }) From 16df8dbb4cf6e03507b5cee43b27833440e2e9a9 Mon Sep 17 00:00:00 2001 From: Will Meister Date: Wed, 29 Apr 2020 11:11:35 -0500 Subject: [PATCH 2/3] fixing issue logging FormattedJsonRpcErrorResponse as error --- .../src/app/routing-handler.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/rollup-full-node/src/app/routing-handler.ts b/packages/rollup-full-node/src/app/routing-handler.ts index 45860235d5b3..eb4014450fbe 100644 --- a/packages/rollup-full-node/src/app/routing-handler.ts +++ b/packages/rollup-full-node/src/app/routing-handler.ts @@ -64,6 +64,7 @@ export class RoutingHandler implements FullnodeHandler { * @param method The Ethereum JSON RPC method. * @param params The parameters. * @param sourceIpAddress The requesting IP address. + * @throws FormattedJsonRpcError if the proxied response is a JsonRpcErrorResponse */ public async handleRequest( method: string, @@ -102,8 +103,9 @@ export class RoutingHandler implements FullnodeHandler { this.assertDestinationValid(tx) + let result: JsonRpcResponse try { - const result: JsonRpcResponse = + result = methodsToRouteWithTransactionHandler.indexOf(method) >= 0 ? await this.transactionClient.makeRpcCall(method, params) : await this.readOnlyClient.makeRpcCall(method, params) @@ -112,22 +114,21 @@ export class RoutingHandler implements FullnodeHandler { params )}] got result [${JSON.stringify(result)}]` ) - if (isJsonRpcErrorResponse(result)) { - throw new FormattedJsonRpcError(result as JsonRpcErrorResponse) - } - return result.result } catch (e) { - if (!(e instanceof FormattedJsonRpcError)) { - logError( - log, - `Error proxying request: [${method}], params: [${JSON.stringify( - params - )}]`, - e - ) - } + logError( + log, + `Error proxying request: [${method}], params: [${JSON.stringify( + params + )}]`, + e + ) throw e } + + if (isJsonRpcErrorResponse(result)) { + throw new FormattedJsonRpcError(result as JsonRpcErrorResponse) + } + return result.result } /** From 9270e3e34a04d2a9de001893602b70f96f2eab72 Mon Sep 17 00:00:00 2001 From: Will Meister Date: Wed, 29 Apr 2020 11:18:06 -0500 Subject: [PATCH 3/3] reverting typo --- packages/rollup-full-node/test/app/routing-handler.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rollup-full-node/test/app/routing-handler.spec.ts b/packages/rollup-full-node/test/app/routing-handler.spec.ts index 9392d4670432..7403fd27693a 100644 --- a/packages/rollup-full-node/test/app/routing-handler.spec.ts +++ b/packages/rollup-full-node/test/app/routing-handler.spec.ts @@ -314,7 +314,7 @@ describe('Routing Handler', () => { error.should.be.instanceOf(FormattedJsonRpcError, 'Invalid error type!') const formatted: FormattedJsonRpcError = error as FormattedJsonRpcError formatted.jsonRpcResponse.should.deep.equal( - transactionErrorRFesponsePayload, + transactionErrorResponsePayload, 'Incorrect error returned!' ) })