Skip to content

Unknown structure name silently falls back or hangs SSR (no validation error) #272

Open

Description

@neil-patel77

Describe the bug

An unknown structure name in infographic syntax is never validated. Depending on the name, the render either:

  1. Silently falls back to a degraded render — e.g. infographic mindmap (not a registered structure; only hierarchy-mindmap exists) renders without any error, but drops the root label and produces a different layout than the real template.
  2. Hangs SSR until the internal 10 s timeout — e.g. infographic nosuchtemplate never fires loaded, so renderToString() rejects with the generic SSR render timeout instead of a descriptive error.

Reproduction

@antv/infographic@0.2.20, Node 22:

const { renderToString } = require('@antv/infographic/ssr');

// Case 1 — silent fallback, wrong output (root label missing):
await renderToString('infographic mindmap\n\ndata\n  root\n    label Root\n    children\n      - label Alpha\n      - label Beta\n');
// resolves OK, but output has no "Root" label and a different layout than hierarchy-mindmap

// Case 2 — SSR hang → generic timeout:
await renderToString('infographic nosuchtemplate\n\ndata\n  a: 1\n');
// rejects after 10 s with: Error: SSR render timeout

For comparison, the correct name renders everything as expected:

await renderToString('infographic hierarchy-mindmap\n\ndata\n  root\n    label Root\n    children\n      - label Alpha\n      - label Beta\n');
// OK — Root, Alpha, Beta all present

Expected behavior

An unknown structure/item/title type should fail fast with a descriptive error, e.g. unknown structure: "mindmap" (did you mean "hierarchy-mindmap"? known: hierarchy-mindmap, list-…, chart-…), instead of silently degrading the output or surfacing as a 10-second SSR timeout.

Root cause

lib/options/parser.js → parseDesignStructure():

const structure = (0, designs_1.getStructure)(type);
if (!structure) return null; // ← unknown type silently becomes null

The registry lookup miss is swallowed; downstream has no structure component and either falls back to a default or (in SSR, lib/ssr/renderer.js) never emits the loaded event, so the 10 s timer rejects with SSR render timeout.

Environment

  • @antv/infographic 0.2.20
  • Node 22, server-side (renderToString from @antv/infographic/ssr)
  • Verified both in a minimal script and through a rendering service built on the SSR API

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions