mermaid-js/mermaid · error · Error
Could not calculate intersection points for rel "${rel.from}
Error message
Could not calculate intersection points for rel "${rel.from}" -> "${rel.to}" What it means
Thrown by drawRels after getIntersectPoints returns a null/undefined startPoint or endPoint. getIntersectPoints calls getIntersectPoint on both shapes; if either shape's intersect function returns no usable point (or the shape has no intersect, though that case throws separately upstream), the result is incomplete and this error fires. It typically indicates degenerate geometry — e.g. a shape with zero width/height — rather than a missing alias.
Source
Thrown at packages/mermaid/src/diagrams/c4/c4Renderer.ts:401
if (rel.techn && rel.techn.text !== '') {
textLimitWidth = calculateTextWidth(rel.techn.text, relConf as TextDimensionConfig);
calcC4ShapeTextWH('techn', rel, relTextWrap, relConf, textLimitWidth);
}
if (rel.descr && rel.descr.text !== '') {
textLimitWidth = calculateTextWidth(rel.descr.text, relConf as TextDimensionConfig);
calcC4ShapeTextWH('descr', rel, relTextWrap, relConf, textLimitWidth);
}
const fromNode = getC4ShapeObj(rel.from);
const endNode = getC4ShapeObj(rel.to);
if (!fromNode || !endNode) {
throw new Error(`C4 rel "${rel.from}" -> "${rel.to}" references an unknown shape`);
}
const points = getIntersectPoints(fromNode, endNode);
if (!points.startPoint || !points.endPoint) {
throw new Error(
`Could not calculate intersection points for rel "${rel.from}" -> "${rel.to}"`
);
}
rel.startPoint = points.startPoint;
rel.endPoint = points.endPoint;
}
svgDraw.drawRels(diagram, rels, conf, diagramId);
};
async function drawInsideBoundary(
diagram: SVG,
parentBoundaryAlias: string,
parentBounds: Bounds,
currentBoundaries: C4Boundary[],
diagObj: Diagram
) {
const db = diagObj.db as C4DB;
const currentBounds = new Bounds(diagObj);View on GitHub (pinned to d93e9c88c0)
Solutions
- Ensure all C4 shapes have non-empty labels and non-zero configured dimensions.
- Simplify the diagram to isolate which relationship/shape triggers the failure.
- If shapes are well-formed and the error persists, report it — the intersection math should not produce null for valid shapes.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await mermaid.render(id, c4DiagramText);
} catch (err) {
if (err instanceof Error && err.message.includes('Could not calculate intersection points')) {
// Likely degenerate shape geometry — ensure non-empty labels and non-zero sizes.
}
throw err;
} Prevention
- Give every C4 shape a non-empty label so it gets a non-zero bounding box.
- Avoid configuring zero or negative shape dimensions.
When it happens
Trigger: A C4 relationship between two shapes where at least one shape has degenerate dimensions (zero width or height) or an intersect function that returns no point. Can also follow from a shape whose intersect was never assigned if the upstream check was bypassed.
Common situations: Shapes with empty labels and a layout that collapses them to zero size; very small/negative dimensions from config; render after a partial earlier failure left shapes unmeasured.
Related errors
- C4 shape "${fromNode.alias}" has no intersect function. Plea
- C4 rel "${rel.from}" -> "${rel.to}" references an unknown sh
- Architecture layout failed: a declared `align row|column` di
- C4: no shape handler for "${node.shape}"
- Line definition not found
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/c65f52aa6c1a9633.
Report an issue: GitHub.