Skip to content

Commit 6d47cdc

Browse files
committed
fix: removed re-throw jsonRpcError for processRpcMethod()
Signed-off-by: Logan Nguyen <[email protected]>
1 parent f1cfb07 commit 6d47cdc

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

packages/relay/src/lib/dispatcher/rpcMethodDispatcher.ts

-7
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,6 @@ export class RpcMethodDispatcher {
134134
// Execute the operation handler with the rearranged parameters
135135
const result = await operationHandler(...rearramgedRpcParams);
136136

137-
// Note: This is a temporary workaround to avoid introducing new logic. However, in follow-up updates,
138-
// all operation handlers should directly throw JSON RPC errors and return only valid results,
139-
// ensuring proper error handling in the centralized handleRpcMethodError component.
140-
if (result instanceof JsonRpcError) {
141-
throw result;
142-
}
143-
144137
return result;
145138
}
146139

packages/relay/tests/lib/dispatcher/rpcMethodDispatcher.spec.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,12 @@ describe('RpcMethodDispatcher', () => {
185185
expect(operationHandler.calledWith(...TEST_PARAMS_REARRANGED_DEFAULT)).to.be.true;
186186
});
187187

188-
it('should throw if handler returns a JsonRpcError', async () => {
188+
it('should directly return JsonRpcError if the handler returns a JsonRpcError', async () => {
189189
const jsonRpcError = new JsonRpcError({ code: -32000, message: 'Handler error' });
190190
operationHandler.returns(jsonRpcError);
191191

192-
try {
193-
await (dispatcher as any).processRpcMethod(operationHandler, TEST_PARAMS, TEST_REQUEST_DETAILS);
194-
expect.fail('Should have thrown an error');
195-
} catch (error) {
196-
expect(error).to.equal(jsonRpcError);
197-
}
192+
const result = await (dispatcher as any).processRpcMethod(operationHandler, TEST_PARAMS, TEST_REQUEST_DETAILS);
193+
expect(result).to.equal(jsonRpcError);
198194
});
199195
});
200196

0 commit comments

Comments
 (0)