Skip to content

Conversation

@tylergannon
Copy link
Contributor

Summary

Fixes truncation of OpenAPI spec output at 64KB when piping to jq or yq.

Problem

The generate command was writing JSON output to stdout without waiting for the write to complete. When the process exits via process.exit() in the finally block, stdout buffers are not fully flushed when writing to a pipe, causing output to be truncated at exactly 65,536 bytes (64KB).

Before this fix:

bun run src/index.ts generate | jq
# jq: parse error: Unfinished JSON term at EOF at line 2605, column 2

After this fix:

bun run src/index.ts generate | jq
# Successfully parses full 181KB spec

Solution

Wait for the process.stdout.write() callback to complete before allowing the process to exit. This ensures all buffered data is flushed to the pipe.

Testing

Verified that piping to both jq and yq now works correctly:

  • bun run src/index.ts generate | jq . - ✅ parses successfully
  • bun run src/index.ts generate | yq -p json -o yaml - ✅ converts successfully

Prevents truncation of OpenAPI spec output at 64KB when piping to jq/yq.
The process.exit() call in the finally block was terminating before
stdout could finish flushing asynchronous writes to the pipe.

Before this fix:
  bun run src/index.ts generate | jq
  # jq: parse error: Unfinished JSON term at EOF at line 2605, column 2

After this fix:
  bun run src/index.ts generate | jq
  # Successfully parses full 181KB spec
@rekram1-node rekram1-node merged commit 7652a96 into sst:dev Nov 3, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants