{"record":{"id":"a9648fc68eb2fec4","repo":"dotnet/aspnetcore","slug":"no-method-defined","errorCode":null,"errorMessage":"No method defined.","messagePattern":"No method defined\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts","lineNumber":66,"sourceCode":"            // @ts-ignore: TS doesn't know about these names\n            const requireFunc = typeof __webpack_require__ === \"function\" ? __non_webpack_require__ : require;\n\n            // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide\n            this._abortControllerType = requireFunc(\"abort-controller\");\n        } else {\n            this._abortControllerType = AbortController;\n        }\n    }\n\n    /** @inheritDoc */\n    public async send(request: HttpRequest): Promise<HttpResponse> {\n        // Check that abort was not signaled before calling send\n        if (request.abortSignal && request.abortSignal.aborted) {\n            throw new AbortError();\n        }\n\n        if (!request.method) {\n            throw new Error(\"No method defined.\");\n        }\n        if (!request.url) {\n            throw new Error(\"No url defined.\");\n        }\n\n        const abortController = new this._abortControllerType();\n\n        let error: any;\n        // Hook our abortSignal into the abort controller\n        if (request.abortSignal) {\n            request.abortSignal.onabort = () => {\n                abortController.abort();\n                error = new AbortError();\n            };\n        }\n\n        // If a timeout has been passed in, setup a timeout to call abort\n        // Type needs to be any to fit window.setTimeout and NodeJS.setTimeout","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts#L48-L84","documentation":"FetchHttpClient.send throws early if the HttpRequest it receives has no method field. The method (GET/POST/etc.) is required for fetch() to make a request; a falsy value indicates the request object was constructed incorrectly upstream.","triggerScenarios":"Calling httpClient.send({...}) with an object missing the method property. Reached indirectly when HttpConnection or the negotiate/long-polling code builds a request from a malformed IHttpConnectionOptions, or when a user-supplied HttpClient returns a request without a method.","commonSituations":"Custom HttpClient wrapper that forwards a partial request. Spread/merge of options that drops the method key. Bug in user code that builds an HttpRequest literal and omits method.","solutions":["Ensure every HttpRequest you construct includes a method field (e.g. \"POST\", \"GET\").","If wrapping HttpClient.send, default method to \"GET\" before delegating.","Add a unit assertion that request.method is non-empty before calling send."],"exampleFix":"// before\nawait httpClient.send({ url: \"https://hub/negotiate\" });\n\n// after\nawait httpClient.send({ method: \"POST\", url: \"https://hub/negotiate\" });","handlingStrategy":"validation","validationCode":"function assertRequest(req: signalR.HttpRequest): void {\n  if (!req.method) throw new Error(\"HttpRequest.method is required\");\n  if (!req.url) throw new Error(\"HttpRequest.url is required\");\n}\n// call before httpClient.send(req)","typeGuard":"function isValidHttpRequest(req: unknown): req is signalR.HttpRequest {\n  return typeof req === \"object\" && req !== null\n    && typeof (req as any).method === \"string\" && (req as any).method.length > 0\n    && typeof (req as any).url === \"string\" && (req as any).url.length > 0;\n}","tryCatchPattern":"try { await httpClient.send(req); }\ncatch (e) {\n  if (e instanceof Error && e.message === \"No method defined.\") {\n    req.method = \"POST\";\n    return httpClient.send(req);\n  }\n  throw e;\n}","preventionTips":["Always build HttpRequest via a small helper that defaults method to 'GET'.","Type the request strictly (no any) so the compiler catches missing fields.","Add a unit test that every code path producing an HttpRequest sets method."],"tags":["http","request-validation","fetch"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}