hcengineering/platform · error
Unknown method${method}
Error message
Unknown method${method} What it means
requestHandler dispatches client requests on a numeric method code (e.g. hello/request-style opcodes) via a switch; the default branch throws for any code the server does not implement. The thrown message concatenates the raw method value, making unsupported opcode attempts identifiable. It signals a protocol-level mismatch between client and server.
Source
Thrown at foundations/net/packages/server/src/server.ts:120
await this.network.release(client, uuid)
await send('ok')
break
}
case opNames.listContainers: {
const kind: ContainerKind = params.kind
await send(await this.network.list(kind))
break
}
case opNames.sendContainer: {
const target: ContainerUuid = params[0]
const operation: string = params[1]
const data: any = params[2]
await send(await this.network.request(target, operation, data))
break
}
default:
throw new Error('Unknown method' + method)
}
}
lastClients = 0
async helloHandler (clientId: ClientUuid): Promise<void> {
if (!this.clients.has(clientId)) {
console.log(`Clients connected: ${this.clients.size}`)
}
this.clients.add(clientId)
this.network.addClient(clientId, async (event) => {
await this.rpcServer.send(clientId, event)
})
}
onPing (client: ClientUuid): void {
this.network.ping(client)
}
View on GitHub (pinned to 63e28dc964)
Solutions
- Check the method value in the error and confirm the client is sending a code this server version supports.
- Align client and server versions so their protocol opcodes match (upgrade the older side).
- Inspect messages between client and server (logs/proxy) for corruption or unexpected method values.
- If you control the codebase, extend requestHandler's switch to implement the new method code server-side.
Example fix
// before
class MyClient extends Client { async ping() { return this.call(99, []) } } // opcode 99 unsupported
// after
class MyClient extends Client { async ping() { return this.call(METHOD_REQUEST, ['ping']) } }
// or server-side:
default:
throw new Error(`Unknown method: ${method}`) // improve message, then add the missing case Defensive patterns
Strategy: try-catch
Validate before calling
const KNOWN_METHODS = new Set([METHOD_HELLO, METHOD_REQUEST /* ... */])
if (!KNOWN_METHODS.has(method)) {
throw new Error(`refusing to send unknown method code ${method}`)
}
await client.call(method, params) Type guard
function isKnownMethod(m: number): m is MethodCode {
return KNOWN_METHODS.has(m as MethodCode)
} Try / catch
try {
await client.call(method, params)
} catch (e) {
if (typeof (e as Error).message === 'string' && e.message.startsWith('Unknown method')) {
console.error(`server rejected method code ${method} — version mismatch or bad opcode`, e)
// renegotiate/upgrade client or fall back to a supported method
} else throw e
} Prevention
- Share a single enum of method codes between client and server packages.
- Negotiate the protocol version in the hello handshake and refuse incompatible peers.
- Never hardcode numeric opcodes at call sites; reference the shared enum.
- Add a conformance test that exercises every supported method code against the server.
When it happens
Trigger: A client sends a request whose method code is outside the handled set — newer client against older server, a corrupted/garbage method value, or a hand-rolled client using the wrong opcode numbers.
Common situations: Version skew where the client added a new method code the running server doesn't know; proxy in front of the server altering or stripping messages; fuzzing or malicious clients sending arbitrary opcodes; misconfigured client pointing at a different service version.
Related errors
- platform.status.BadRequest
- Unknown method${method}
- Unknown method
- platform.status.ConnectionClosed
- HTTP error ${res.status}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/c96fbd9adfba5a2f.
Report an issue: GitHub.