Skip to content

fix: process.stdout.write instead of console.log for export cmd#3049

Merged
rekram1-node merged 2 commits into
anomalyco:devfrom
veracioux:bugfix/export-truncated-stdout
Oct 9, 2025
Merged

fix: process.stdout.write instead of console.log for export cmd#3049
rekram1-node merged 2 commits into
anomalyco:devfrom
veracioux:bugfix/export-truncated-stdout

Conversation

@veracioux
Copy link
Copy Markdown
Contributor

@veracioux veracioux commented Oct 8, 2025

This makes sure that all of the output is written before the command exits.

Verified by:

opencode export <sessionID>: produces expected output.
opencode export <sessionID> | jq: produces expected output.

For very large data, one could try to mock a session with a lot of data. I opted
for the simpler approach of just replacing the changed code with the following:

const data = 'a'.repeat(1024**3) // 1GiB of data should be more than enough safety margin
process.stdout.write(JSON.stringify(exportData, null, 2))

and running opencode export <sessionID> | wc -c, which printed 1073741824,
which indeed corresponds to 1GiB.

This makes sure that all of the output is written before the
command exits.
Comment thread packages/opencode/src/cli/cmd/export.ts
@rekram1-node rekram1-node changed the title fix: Use process.stdout.write instead of console.log for export output fix: process.stdout.write instead of console.log for export cmd Oct 9, 2025
@rekram1-node rekram1-node merged commit c5b5795 into anomalyco:dev Oct 9, 2025
3 checks passed
@veracioux veracioux deleted the bugfix/export-truncated-stdout branch November 12, 2025 12:54
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Rwanbt pushed a commit to Rwanbt/opencode that referenced this pull request May 5, 2026
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.

3 participants