MCPcopy Index your code
hub / github.com/rilldata/rill / handleRPCMessage

Function handleRPCMessage

web-common/src/lib/rpc.ts:35–62  ·  view source on GitHub ↗
(event: MessageEvent<JSONRPCRequest>)

Source from the content-addressed store, hash-verified

33};
34
35async function handleRPCMessage(event: MessageEvent<JSONRPCRequest>) {
36 if (typeof event.data !== "object" || event.data === null) {
37 return sendError(null, JSONRPC_ERRORS.INVALID_REQUEST);
38 }
39
40 const { id = null, method, params } = event.data;
41
42 if (typeof method !== "string") {
43 return sendError(id, JSONRPC_ERRORS.INVALID_REQUEST);
44 }
45
46 if (!methods[method]) {
47 return sendError(id, JSONRPC_ERRORS.METHOD_NOT_FOUND);
48 }
49
50 try {
51 const result = await methods[method](params);
52 if (id !== null) {
53 sendResponse(id, result);
54 }
55 } catch (error) {
56 const errorMessage = error instanceof Error ? error.message : String(error);
57 sendError(id, {
58 code: JSONRPC_ERRORS.INTERNAL_ERROR.code,
59 message: errorMessage,
60 });
61 }
62}
63
64function sendResponse(id: string | number | null, result: unknown) {
65 if (window.parent !== window) {

Callers 1

handlerFunction · 0.85

Calls 3

sendErrorFunction · 0.85
sendResponseFunction · 0.85
StringFunction · 0.85

Tested by

no test coverage detected