{"record":{"id":"fafd3ad427edee3f","repo":"microsoft/typescript-go","slug":"unknown-method-s","errorCode":null,"errorMessage":"unknown method: %s","messagePattern":"unknown method: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/api/session.go","lineNumber":865,"sourceCode":"\t\treturn s.handleGetGlobalDiagnostics(ctx, parsed.(*GetProjectDiagnosticsParams))\n\tcase string(MethodGetConfigFileParsingDiagnostics):\n\t\treturn s.handleGetConfigFileParsingDiagnostics(ctx, parsed.(*GetProjectDiagnosticsParams))\n\tcase string(MethodStartCPUProfile):\n\t\treturn s.handleStartCPUProfile(ctx, parsed.(*ProfileParams))\n\tcase string(MethodStopCPUProfile):\n\t\treturn s.handleStopCPUProfile(ctx)\n\tcase string(MethodSaveHeapProfile):\n\t\treturn s.handleSaveHeapProfile(ctx, parsed.(*ProfileParams))\n\tcase string(MethodGetReferencesToSymbolInFile):\n\t\treturn s.handleGetReferencesToSymbolInFile(ctx, parsed.(*GetReferencesToSymbolInFileParams))\n\tcase string(MethodGetReferencedSymbolsForNode):\n\t\treturn s.handleGetReferencedSymbolsForNode(ctx, parsed.(*GetReferencedSymbolsForNodeParams))\n\tcase string(MethodGetSignatureUsages):\n\t\treturn s.handleGetSignatureUsages(ctx, parsed.(*GetSignatureUsagesParams))\n\tcase string(MethodGetCompletionsAtPosition):\n\t\treturn s.handleGetCompletionsAtPosition(ctx, parsed.(*GetCompletionsAtPositionParams))\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown method: %s\", method)\n\t}\n}\n\nfunc (s *Session) handleStartCPUProfile(_ context.Context, params *ProfileParams) (any, error) {\n\tif params == nil || params.Dir == \"\" {\n\t\treturn nil, fmt.Errorf(\"%w: dir is required\", ErrClientError)\n\t}\n\tif err := s.cpuProfiler.StartCPUProfile(params.Dir); err != nil {\n\t\treturn nil, fmt.Errorf(\"%w: failed to start CPU profile: %w\", ErrClientError, err)\n\t}\n\treturn nil, nil\n}\n\nfunc (s *Session) handleStopCPUProfile(_ context.Context) (*ProfileResult, error) {\n\tfilePath, err := s.cpuProfiler.StopCPUProfile()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%w: failed to stop CPU profile: %w\", ErrClientError, err)\n\t}","sourceCodeStart":847,"sourceCodeEnd":883,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/session.go#L847-L883","documentation":"The request's method string matched no case in Session.HandleRequest's dispatch switch and no unmarshaler in proto.go, so the session rejects it with a plain error (no sentinel wrapper). Note that getServerTiming and resetServerTiming are handled by the connection layer, not the session, so they also fail if routed to a raw session handler.","triggerScenarios":"Typo in the method name (\"getSymbolAtPositin\"); calling a method that only exists in a newer typescript-go than the server binary; sending connection-level methods (getServerTiming, resetServerTiming) directly to the session handler.","commonSituations":"Client and server built from different versions of the repo so the method list diverges; string literals for method names drifting from the Method* constants during refactors; copy-paste from older protocol docs.","solutions":["Use the exported Method constants (api.MethodGetCompletionsAtPosition etc.) instead of string literals","Check whether the server build actually contains the method (grep proto.go unmarshalers for the version you deploy)","Upgrade the older side so client and server agree on the protocol"],"exampleFix":"// before\nresp, err := conn.Call(ctx, \"getCompletionsAtPositin\", params)\n\n// after\nresp, err := conn.Call(ctx, string(api.MethodGetCompletionsAtPosition), params)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isKnownMethod(m string) bool {\n    switch api.Method(m) {\n    case api.MethodRelease, api.MethodInitialize, api.MethodUpdateSnapshot,\n        api.MethodUpdateTemporarySnapshot, api.MethodParseCommandLine,\n        api.MethodReadConfigFile, api.MethodParseJsonConfigFile,\n        api.MethodParseConfigFile, api.MethodTranspileModule,\n        api.MethodGetCompletionsAtPosition /* ... extend from proto.go */:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err != nil && strings.HasPrefix(err.Error(), \"unknown method:\") {\n    // typo or version skew: check the method name against api.Method constants\n}","preventionTips":["Reference api.Method* constants instead of raw strings","Route getServerTiming/resetServerTiming through the connection layer, not the session","After upgrading either side, run a smoke test of every method your client uses"],"tags":["dispatch","method-name","version-skew","api"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}