From ef59b231e64586b857e6f65c396f39c9949fe0f5 Mon Sep 17 00:00:00 2001 From: jamie-at-bunny Date: Wed, 6 May 2026 16:13:19 +0100 Subject: [PATCH 1/2] fix(cli/api): drain stdout before exit to avoid pipe truncation --- packages/cli/src/commands/api.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/api.ts b/packages/cli/src/commands/api.ts index d391a0d..e7c96c3 100644 --- a/packages/cli/src/commands/api.ts +++ b/packages/cli/src/commands/api.ts @@ -167,14 +167,14 @@ export const apiCommand = defineCommand({ text || undefined, ); } - if (text) logger.log(text); + if (text) await writeStdout(`${text}\n`); return; } if (!res.ok) { if (output === "json") { - logger.log( - JSON.stringify({ error: parsed, status: res.status }, null, 2), + await writeStdout( + `${JSON.stringify({ error: parsed, status: res.status }, null, 2)}\n`, ); } else { const msg = @@ -189,6 +189,17 @@ export const apiCommand = defineCommand({ process.exit(1); } - logger.log(JSON.stringify(parsed, null, 2)); + await writeStdout(`${JSON.stringify(parsed, null, 2)}\n`); }, }); + +/** + * Await the write callback so large payloads piped to another process aren't + * truncated — console.log to a POSIX pipe is async (with no way to wait for + * it), and the runtime can exit before the buffer drains. + */ +function writeStdout(data: string): Promise { + return new Promise((resolve, reject) => { + process.stdout.write(data, (err) => (err ? reject(err) : resolve())); + }); +} From afc70ed2a4b9b72643570cda2773dd2af824e41b Mon Sep 17 00:00:00 2001 From: jamie-at-bunny Date: Thu, 7 May 2026 08:06:58 +0100 Subject: [PATCH 2/2] changeset --- .changeset/social-webs-enter.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/social-webs-enter.md diff --git a/.changeset/social-webs-enter.md b/.changeset/social-webs-enter.md new file mode 100644 index 0000000..03f2b9b --- /dev/null +++ b/.changeset/social-webs-enter.md @@ -0,0 +1,5 @@ +--- +"@bunny.net/cli": patch +--- + +bunny api no longer truncates large JSON responses when piping