Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublicTeam
Assigneesstack72

Relationships

#3253 data query --select content crashes with 'Maximum call stack size exceeded' in the terminal markdown renderer for large file data (~10 MB), even when stdout is redirected

Opened by taylor · 10/11/2026· Shipped 10/11/2026

What happens

swamp data query '<predicate>' --select content crashes for large file data. It prints RangeError: Maximum call stack size exceeded from marked (the terminal markdown renderer), writes nothing to stdout, and exits 1. It crashes the same way when stdout is redirected to a file or a pipe, so the documented way to read a file's content (swamp data query 'model("<m>") && name == "<d>"' --select content, replacing the deprecated data get) silently produces an empty file for large artifacts.

Adding --json avoids the crash, so the content can be retrieved, just not through the default output.

Steps to reproduce

Swamp 20261009.215038.0-sha.986f9022, macOS. The data is PNG screenshots written by a model through createFileWriter(...).writeAll(bytes) (file spec, contentType: image/png). Output is redirected to a file in every case:

data size exit stdout stderr
66,812 B 0 89,087 B (base64) none
1,021,053 B 0 1,361,407 B none
2,552,739 B 0 3,403,655 B none
10,175,917 B 1 0 B RangeError: Maximum call stack size exceeded
swamp data query 'model("webshot") && name == "far-future"' --select content > out.b64
# exit 1, out.b64 is empty
[FTL] error: RangeError: Maximum call stack size exceeded
Please report this to https://github.com/markedjs/marked.
    at RegExp.exec (<anonymous>)
    at _Tokenizer.lheading (.../marked/14.1.4/lib/marked.esm.js:470:47)
    at _Lexer.blockTokens (.../marked/14.1.4/lib/marked.esm.js:192:40)
    at _Lexer.lex (.../marked/14.1.4/lib/marked.esm.js:76:14)
    at Marked.parse (.../marked/14.1.4/lib/marked.esm.js:282:30)
    at renderMarkdownToTerminal (src/presentation/markdown_renderer.ts:60:33)
    at renderQueryResultsTerminal (src/presentation/renderers/data_query.ts:305:12)
    at completed (src/presentation/renderers/data_query.ts:345:21)
    at consumeStream (src/libswamp/stream.ts:57:11)

Workaround:

swamp data query '<predicate>' --select content --json | jq -r '.results[0]' | base64 -D > out.png

Expected

  • --select content writes the content for data of any size, at least when stdout is not a TTY, without passing it through the markdown renderer. A multi-megabyte base64 string is not markdown. marked's lheading regex appears to recurse or backtrack on a single huge line.
  • If rendering does fail, swamp should fall back to raw output or exit non-zero with a clear message. Today it leaves an empty output file.

Notes

  • The size threshold is somewhere between 2.5 MB and 10 MB of data (3.4 MB and 13.6 MB of base64).
  • Not the same as #2565, a different stack overflow, in version handling.
02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 7 MOREPR_MERGED+ 2 MORESESSION_SUMMARIZED

Shipped

10/11/2026, 9:27:42 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack7210/11/2026, 8:51:14 PM
Editable. Press Enter to edit.

stack72 commented 10/11/2026, 9:27:45 PM

Thanks @taylor for reporting this! We shipped: data query --select content crashes for large data because scalar projections are passed through the marked markdown renderer, whose lheading tokenizer overflows the stack on a multi-megabyte line. Fix: write scalar projections verbatim in log mode, which also stops markdown syntax in content being rendered away. Map/list tables are unchanged.. The fix has been merged and a release is on its way. We appreciate your contribution to swamp.

Sign in to post a ripple.