[PR #3049] fix: process.stdout.write instead of console.log for export cmd #10518

Closed
opened 2026-02-16 18:15:11 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3049

State: closed
Merged: Yes


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.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3049 **State:** closed **Merged:** Yes --- 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: ```js 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.
yindo added the pull-request label 2026-02-16 18:15:11 -05:00
yindo closed this issue 2026-02-16 18:15:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10518