From 6e44852171eee58815d188a1d029039b059d7cbe Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 14:40:21 +0000 Subject: [PATCH 1/3] fix: preserve newlines in heredoc commands for exec() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes heredoc commands hanging in foreground execution by wrapping commands with newlines instead of placing them on a single line. Heredoc terminators must appear alone on their own line to work correctly. Fixes #139 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: deathbyknowledge --- packages/sandbox-container/src/session.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/sandbox-container/src/session.ts b/packages/sandbox-container/src/session.ts index c6e588b2..5c6d8123 100644 --- a/packages/sandbox-container/src/session.ts +++ b/packages/sandbox-container/src/session.ts @@ -698,7 +698,9 @@ export class Session { script += ` PREV_DIR=$(pwd)\n`; script += ` if cd ${safeCwd}; then\n`; script += ` # Execute command with prefixed streaming via process substitution\n`; - script += ` { ${command}; } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`; + script += ` {\n`; + script += `${command}\n`; + script += ` } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`; script += ` EXIT_CODE=$?\n`; script += ` # Restore directory\n`; script += ` cd "$PREV_DIR"\n`; @@ -708,7 +710,9 @@ export class Session { script += ` fi\n`; } else { script += ` # Execute command with prefixed streaming via process substitution\n`; - script += ` { ${command}; } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`; + script += ` {\n`; + script += `${command}\n`; + script += ` } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`; script += ` EXIT_CODE=$?\n`; } From 4d504b7da61b2e02f7ef39a128d887857b7a45c0 Mon Sep 17 00:00:00 2001 From: Steve James Date: Thu, 23 Oct 2025 17:17:26 +0200 Subject: [PATCH 2/3] patch to get preview pkg --- .github/workflows/pkg-pr-new.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pkg-pr-new.yml b/.github/workflows/pkg-pr-new.yml index 96747b84..4cb06c72 100644 --- a/.github/workflows/pkg-pr-new.yml +++ b/.github/workflows/pkg-pr-new.yml @@ -7,9 +7,9 @@ permissions: on: pull_request: types: [opened, synchronize, reopened] - paths: - - '!**/*.md' - - '!.changeset/**' + #paths: + # - '!**/*.md' + # - '!.changeset/**' jobs: From 6d38e268a5c5c7f461aa1468ac6243e1bddada9a Mon Sep 17 00:00:00 2001 From: Naresh Date: Thu, 23 Oct 2025 19:08:52 +0100 Subject: [PATCH 3/3] Add changeset Fixes the handling of newlines in heredoc commands when using exec(). --- .changeset/ten-mangos-cover.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/ten-mangos-cover.md diff --git a/.changeset/ten-mangos-cover.md b/.changeset/ten-mangos-cover.md new file mode 100644 index 00000000..367aacf4 --- /dev/null +++ b/.changeset/ten-mangos-cover.md @@ -0,0 +1,6 @@ +--- +"@repo/sandbox-container": patch +"@cloudflare/sandbox": patch +--- + +fix: preserve newlines in heredoc commands for exec()