makesPDF
← All updates

Very large markdown documents fail fast instead of hogging the render

A 200KB document made of thousands of one-line list items, table rows or headings could spend ~30s laying out and then time out. Those shapes now get an instant 400 naming the fix; ordinary documents are unchanged.

markdownapilimits

The 200KB markdown text cap bounded how much text you could send, not how much work laying it out would take. A document made of thousands of very short blocks - one-line list items, table rows, headings, horizontal rules, or a very long code block - could pass every existing check and then spend tens of seconds in layout before the request died. 200KB of - a list lines measured about 30 seconds; the same markdown wrapped in a code fence was equally expensive.

That work now happens up front. /api/v1/md (and /api/v1/markdown and the MCP render_markdown tool) estimate the layout cost of the converted document before laying it out, and a document over the budget is refused in roughly the time it takes to parse it - about a second for a 200KB document - with:

{
  "error": "markdown is too large to lay out in reasonable time (over the 3s estimated layout budget); see `hint` for what to change",
  "code": "markdown-too-complex",
  "rule": "layout-work",
  "hint": "The document is shaped so that laying it out would take seconds: thousands of very short blocks ..."
}

It is the same code family as the existing parsing limit, with rule telling you which bound you hit. Nothing is billed: API-key calls deduct zero credits, wallet calls are marked for refund, and the free anonymous lane answers the same way. Very large diagram sets count as well: each distinct Mermaid or graph block is rendered before layout, so a document made of thousands of tiny diagrams is refused the same way.

Ordinary documents are untouched. 200KB of ordinary prose, a 200KB list whose items are sentences, a 60KB block of inline code, and every sample on this site still render exactly as before - the estimate is about element count, not size. If you do hit the limit, join short items into longer blocks or paragraphs, split the document across requests, or replace a huge repeated table with a link to the data. The full bound and the shapes it admits are recorded in the API limits.