Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneeszack

Relationships

#4940 `swamp data query --json` fails with "Invalid string length" once results exceed V8's maximum string length

Opened by zack · 11/20/2026· Shipped 11/20/2026

Description

swamp data query <predicate> --select content --json builds the whole result document with one JSON.stringify call before writing it. When the selected content adds up to more than V8's maximum string length (about 512 MiB), the command fails regardless of the heap limit:

{"error": "Invalid string length",
 "stack": "at JSON.stringify (<anonymous>)
           at renderJson (src/presentation/renderers/data_query.ts:218:22)
           at completed (src/presentation/renderers/data_query.ts:341:11)
           at consumeStream (src/libswamp/stream.ts:46:11)
           at async Command.<anonymous> (src/cli/commands/data_query.ts:289:3) ..."}

Reproduction

  1. Have a behavior whose resources are large: in our case one behavior has six resources with latest versions of 56 MB, 390 MB, 161 MB, 173 MB, 1.3 MB and 0.3 KB of JSON content.
  2. Query them together: swamp data query 'modelName == "<name>" && (name == "a" || name == "b" || ...)' --select content --json
  3. The command exits non-zero with the error above. Querying each resource on its own succeeds, because each single result stays under the limit.

Expected

Query output memory and output size do not depend on a single in-memory string. With --json, results are written incrementally (record by record, or as NDJSON behind a flag), so any result set that fits on disk can be printed. A single record larger than the string limit should fail with an error naming that record, not a bare V8 message.

Version

swamp 20261119.221526.0-sha.b21dc9b8, Linux x86_64

02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 17 MOREPR_LINKED+ 2 MORESESSION_SUMMARIZED

Shipped

11/20/2026, 4:41:31 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
zack assigned zack11/20/2026, 3:13:17 PM

Sign in to post a ripple.