Skip to content

fix: disable bg-pty-host factory via native chunk source rewrite - #260

Open
bash0816 wants to merge 4 commits into
mainfrom
fix/dys-rewrite-bg-pty-host-v3
Open

fix: disable bg-pty-host factory via native chunk source rewrite#260
bash0816 wants to merge 4 commits into
mainfrom
fix/dys-rewrite-bg-pty-host-v3

Conversation

@bash0816

@bash0816 bash0816 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • bg-pty-host無限respawnバグの修正。dYs()(bg-pty-host用PTYファクトリ関数)のバンドルソース自体を書き換えundefinedを返すようにすることで、doSpawn()if (!this.spawnPty)分岐を確実に発火させ、upstream既存の安全な終端経路(settle("crashed")、respawnなし)に乗せる。
  • G1(v9)・G2(v9)・G3すべてGPT-5.6-terraでGo(Blockerなし)。G3ではterra自身が実際の2.1.220-3バンドルに対して正規表現・書き換え・評価を直接検証済み。

Test plan

  • node --test packages/claude-code/lib/termux-run-claude-native.test.js — 58 PASS / 0 FAIL
  • G3コーディングレビュー Go(terraが実バンドルでも動作確認)
  • G4検証レビュー: 実機でclaude -p非退行・background/fleet job 2種のcrashed確定・respawnなし確認(ユーザー本人実施予定)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0603dfc16

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const stdioMapped = Array.isArray(stdioArrayRaw)
? stdioArrayRaw.map(normalizeStdio)
: [normalizeStdio(opts.stdin), normalizeStdio(opts.stdout), normalizeStdio(opts.stderr)];
const child = _realChild.spawn(cmdArray[0], cmdArray.slice(1), {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Route Bun.spawn through the update guard

When the upstream bundle uses the new Bun.spawn shim to launch an npm/pnpm/yarn/npx update path, this delegates straight to the real child_process.spawn instead of the guarded child-process wrapper that blocks official self-updates. That creates a second process-spawning API which bypasses native-update-guard.js, so the same command blocked through require('child_process') can run if reached through Bun.spawn; build the shim on the guarded child process object instead.

Useful? React with 👍 / 👎.

Comment on lines +830 to +831
child.on('exit', (code, signal) => resolveExited(code !== null ? code : (signal ? 128 : 0)));
child.on('error', () => resolveExited(1));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for stdio close before resolving spawned output

When a spawned command writes stdout that can still be draining after the process exits, resolving exited from the child exit event lets stdout.text() return before the stdout pipe has emitted all data. Since Node's close event is the point where stdio streams are closed, this can truncate output for Bun.spawn(...).stdout.text() callers; resolve the text reader after stdout/child close rather than just process exit.

Useful? React with 👍 / 👎.

@bash0816
bash0816 force-pushed the fix/dys-rewrite-bg-pty-host-v3 branch from b0603df to 5b9e025 Compare August 5, 2026 10:56
Upstream released 2.1.222 while the 220-3 fix (bg-pty-host factory
disable via native chunk source rewrite) was still awaiting G4. Rather
than chase the intermediate 2.1.221, rebase the fix onto the 2.1.222
intake and republish the wrapper as 2.1.222-1.

Verified the existing regex-based rewrite still matches exactly once
against the real 2.1.222 native bundle (offsets 256895476/279849039)
and that the patched factory function returns undefined, using the
production rewriteNativeChunkSource() from both helper and bootstrap
branches.
@bash0816
bash0816 force-pushed the fix/dys-rewrite-bg-pty-host-v3 branch from 5b9e025 to 25ef6fb Compare August 5, 2026 23:16
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.

1 participant