dotnet/aspnetcore · error · Error
Invalid component type
Error message
Invalid component type '${type}'. What it means
Thrown by parseCommentPayload after JSON.parse of a component comment if the resulting object's 'type' field is not one of 'server', 'webassembly', or 'auto'. These three are the only supported component marker types; any other value (or missing type) is rejected before the payload is returned.
Solutions
- Ensure the prerendering layer emits exactly 'server', 'webassembly', or 'auto'.
- Update the client-side Blazor runtime to match the server's version so all marker types are recognized.
- Remove any custom code that synthesizes Blazor component markers.
- Inspect the comment payload in the served HTML and correct the type field.
Defensive patterns
Strategy: validation
Validate before calling
const VALID = new Set(['server', 'webassembly', 'auto']);
function assertMarkerType(payload: any) {
if (!VALID.has(payload?.type)) {
throw new Error(`Unsupported marker type '${payload?.type}'.`);
}
} Type guard
function isMarkerType(v: unknown): v is 'server' | 'webassembly' | 'auto' {
return v === 'server' || v === 'webassembly' || v === 'auto';
} Prevention
- Only emit official marker types from the prerendering pipeline.
- Align server and client runtime versions.
- Don't synthesize Blazor component markers in custom code.
When it happens
Trigger: A Blazor component comment with type set to an unrecognized string (e.g. 'client', 'razor'); the type field missing so it is undefined; a hand-crafted or corrupted marker.
Common situations: Custom tooling that emits component markers with a non-standard type; corruption of the JSON payload; a future/newer Blazor version emitting a type this older runtime doesn't know.
Related errors
- assembly must be defined when using a descriptor.
- descriptor must be defined when using a descriptor.
- Error parsing the sequence
- Invalid end of component comment
- sequence must be defined when using a descriptor.
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/9c8518fc1c5f609a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Components/Web.JS/src/Services/ComponentDescriptorDiscovery.ts:173
case 'server':
return createServerComponentComment(componentComment, candidateStart as Comment, candidateEnd);
case 'auto':
return createAutoComponentComment(componentComment, candidateStart as Comment, candidateEnd);
}
} catch (error) {
throw new Error(`Found malformed component comment at ${candidateStart.textContent}`);
}
} else {
return;
}
}
}
function parseCommentPayload(json: string): ServerComponentMarker | WebAssemblyComponentMarker | AutoComponentMarker {
const payload = JSON.parse(json);
const { type } = payload;
if (type !== 'server' && type !== 'webassembly' && type !== 'auto') {
throw new Error(`Invalid component type '${type}'.`);
}
return payload;
}
function assertNotDirectlyOnDocument(marker: Node) {
if (marker.parentNode instanceof Document) {
throw new Error('Root components cannot be marked as interactive. The <html> element must be rendered statically so that scripts are not evaluated multiple times.');
}
}
function getComponentEndComment(payload: ComponentMarker, start: Comment, iterator: ComponentCommentIterator): Comment | undefined {
const { prerenderId } = payload;
if (!prerenderId) {
return undefined;
}
while (iterator.next() && iterator.currentElement) {View on GitHub (pinned to 3600ca084e)