{"record":{"id":"80d7dac4dfa02bac","repo":"hcengineering/platform","slug":"method-methodname-not-found-in-service-implem","errorCode":null,"errorMessage":"Method '${methodName}' not found in service implementation","messagePattern":"Method '(.+?)' not found in service implementation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/packages/core/src/proxy.ts","lineNumber":111,"sourceCode":" * ```\n */\nexport async function handleProxyCall<T extends ServiceImplementation> (\n  implementation: T,\n  method: string,\n  params: any[],\n  interfaceName?: string\n): Promise<any> {\n  // Strip interface name prefix if present\n  let methodName = method\n  if (interfaceName !== undefined && method.startsWith(`${interfaceName}.`)) {\n    methodName = method.substring(interfaceName.length + 1)\n  }\n\n  // Get the method from the implementation\n  const fn = implementation[methodName]\n\n  if (fn === undefined || typeof fn !== 'function') {\n    throw new Error(`Method '${methodName}' not found in service implementation`)\n  }\n\n  // Call the method with the provided parameters\n  const result = await fn.apply(implementation, params)\n  return result\n}\n\n/**\n * Creates a request handler wrapper for a service implementation.\n * This is a convenience function that wraps handleProxyCall.\n *\n * @template T - The service interface type\n * @param implementation - The actual implementation of the service interface\n * @param interfaceName - Optional interface name prefix to strip from method names\n * @returns A request handler function\n *\n * @example\n * ```typescript","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/packages/core/src/proxy.ts#L93-L129","documentation":"handleProxyCall receives a remote method invocation (proxy requests) and looks the method name up on the registered service implementation before invoking it with the given params. If the property is missing or not a function, the library throws, since there is no code to execute for that RPC. This surfaces a client/server contract mismatch.","triggerScenarios":"A client proxy invokes methodName that does not exist on the server-side implementation object — method renamed or removed on the server, client generated against an older service interface, or a typo in the method name.","commonSituations":"Version skew: client updated to a new interface while server still runs the old implementation; calling an internal/private helper that isn't part of the service; passing the wrong implementation object when registering the service; TypeScript types out of sync across packages.","solutions":["Compare the method invoked by the client with the actual methods on the server implementation; fix the name mismatch.","Deploy matching versions of client and server so the service interface is identical on both sides.","Verify the correct implementation object was registered for the service (not an empty or wrong object).","Add a shared interface/type for the service and typecheck both sides to catch drift at build time."],"exampleFix":"// before (server)\nregisterService('calc', { add: (a, b) => a + b })\n// client calls proxy.subtract(3, 1) -> throws\n// after\nregisterService('calc', {\n  add: (a, b) => a + b,\n  subtract: (a, b) => a - b\n}) // or update client to only call add","handlingStrategy":"type-guard","validationCode":"// Client-side check before invoking the proxy:\nif (typeof (serviceImplementation as any)?.[methodName] !== 'function') {\n  throw new Error(`service does not implement ${methodName}`)\n}","typeGuard":"function hasMethod<T extends object>(impl: T, m: string): impl is T & Record<typeof m, (...args: any[]) => any> {\n  return typeof (impl as any)[m] === 'function'\n}\n\nif (!hasMethod(implementation, methodName)) throw new Error(`missing method ${methodName}`)","tryCatchPattern":"try {\n  return await proxy[methodName](...args)\n} catch (e) {\n  if (typeof (e as Error).message === 'string' && e.message.includes('not found in service implementation')) {\n    console.error(`RPC contract mismatch: ${methodName} missing on server`, e)\n    // surface a typed RemoteMethodNotFound error to the caller\n  }\n  throw e\n}","preventionTips":["Define the service interface in a shared package consumed by both client and server, and typecheck both.","Keep client and server deployments version-locked; reject incompatible versions at handshake.","Never rely on stringly-typed method names — derive them from the shared interface keys.","Add an integration test that calls every interface method through the proxy."],"tags":["rpc","proxy","contract-mismatch","service"],"backgroundTag":"method-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}