dotnet/aspnetcore · error · Error
No method defined.
Error message
No method defined.
What it means
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.
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.
Example fix
// before
await httpClient.send({ url: "https://hub/negotiate" });
// after
await httpClient.send({ method: "POST", url: "https://hub/negotiate" }); Defensive patterns
Strategy: validation
Validate before calling
function assertRequest(req: signalR.HttpRequest): void {
if (!req.method) throw new Error("HttpRequest.method is required");
if (!req.url) throw new Error("HttpRequest.url is required");
}
// call before httpClient.send(req) Type guard
function isValidHttpRequest(req: unknown): req is signalR.HttpRequest {
return typeof req === "object" && req !== null
&& typeof (req as any).method === "string" && (req as any).method.length > 0
&& typeof (req as any).url === "string" && (req as any).url.length > 0;
} Try / catch
try { await httpClient.send(req); }
catch (e) {
if (e instanceof Error && e.message === "No method defined.") {
req.method = "POST";
return httpClient.send(req);
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No url defined.
- is not supported.
- errorMessage || response.statusText
- Failed to download , Status Code
- Invalid authentication refresh response received: expected…
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/a9648fc68eb2fec4.
Report an issue: GitHub.
Appendix: source
Thrown at src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts:66
// @ts-ignore: TS doesn't know about these names
const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
// Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
this._abortControllerType = requireFunc("abort-controller");
} else {
this._abortControllerType = AbortController;
}
}
/** @inheritDoc */
public async send(request: HttpRequest): Promise<HttpResponse> {
// Check that abort was not signaled before calling send
if (request.abortSignal && request.abortSignal.aborted) {
throw new AbortError();
}
if (!request.method) {
throw new Error("No method defined.");
}
if (!request.url) {
throw new Error("No url defined.");
}
const abortController = new this._abortControllerType();
let error: any;
// Hook our abortSignal into the abort controller
if (request.abortSignal) {
request.abortSignal.onabort = () => {
abortController.abort();
error = new AbortError();
};
}
// If a timeout has been passed in, setup a timeout to call abort
// Type needs to be any to fit window.setTimeout and NodeJS.setTimeoutView on GitHub (pinned to 3600ca084e)