Skip to content

fix(process-host): accept string stdin in the synchronous process runner - #27683

Closed
jespo2021 wants to merge 1 commit into
stablyai:mainfrom
jespo2021:fix/run-process-sync-string-input
Closed

jespo2021 wants to merge 1 commit into
stablyai:mainfrom
jespo2021:fix/run-process-sync-string-input

Conversation

@jespo2021

Copy link
Copy Markdown
Contributor

ELI5

Importing Chrome cookies on Windows failed every time with a message blaming the OS. The real cause was a small mistake in how Orca starts a helper program, and this fixes it.

What Changed

Before: Settings → Browser → Import on Windows failed with 'Could not access Google Chrome encryption key', and the diagnostic log showed ERR_UNKNOWN_ENCODING: Unknown encoding: buffer. After: the helper that reads Chrome's key actually runs.

runProcessSync passed encoding: 'buffer' to spawnSync. Node also uses that value to encode a string input, and 'buffer' isn't a valid encoding there, so it threw before the child process started. It now passes encoding: null, which still returns Buffers, so the output handling is unchanged.

Why

Any synchronous caller that sends a string to stdin hit this, and the cookie key helper is the one users see. I considered converting the input to a Buffer first, but null is the documented way to ask for raw output and it's a one-word change. I left the 'OS may have denied access' wording alone to keep this small, so a real key failure still reads the same as before.

This overlaps #19298 and #19304, which fix the same bug for #18670. Both were opened on 2026-09-07 against src/shared/child-process/run-process.ts, and that code has since moved to src/packages/process-host, so I don't think they apply to main any more. I'm happy to close this one if a maintainer would rather revive either of those.

Linked Issue

Fixes #27617

Visual Proof

N/A - no UI change, this only stops the helper process from failing to start.

Testing

I reproduced the throw with plain Node on macOS (spawnSync with string input and encoding: 'buffer' throws, null works), then added a regression test that feeds string input through runProcessSync. It fails without the fix. pnpm test on the process runner suites passes (3 files, 29 tests), along with pnpm tc:node, oxlint, oxfmt --check and pnpm run check:code-quality:changed. I did not run the cookie import on Windows, I don't have a Windows machine here.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Claude Opus 5.5 (Claude Code) picked the issue, confirmed the cause, and wrote the change and the test. I reviewed the diff before opening this.

Review

  • Cross-platform: the runner is shared, and the new test runs on every platform. The visible bug was Windows only because that's where the key helper takes stdin.
  • SSH/remote/local: no change to where processes run.
  • Agents and integrations: none affected.
  • Performance: none.
  • Security: no new input paths, the Windows spawn rules in process-host are untouched.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

This doesn't add support for Chrome's app-bound cookie encryption, it only removes the exception that hid whatever happens next.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

runProcessSync passed encoding 'buffer' to spawnSync, which also uses
that value to encode a string input and throws ERR_UNKNOWN_ENCODING.
On Windows that broke Chrome cookie import before the key helper ran.
Pass null instead, which still returns Buffers.

Fixes stablyai#27617
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2115442-9e09-4a30-acf2-092c9a3665cf

📥 Commits

Reviewing files that changed from the base of the PR and between cfb63dc and 953052e.


📒 Files selected for processing (2)
  • src/packages/process-host/src/run-process.test.ts
  • src/packages/process-host/src/run-process.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.



📝 Walkthrough

Walkthrough

runProcessSync now passes null as the spawnSync encoding. A new test supplies a Unicode string as stdin and checks that stdout contains the same string and the process exits with code 0.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 95305

Windows Chrome key extraction can now pass string stdin without the encoding exception, and the regression test covers the helper’s Unicode round trip. No concrete merge-blocking risk remains in this change.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check Warning Direct issue [#27617] requires the synchronous helper to accept string stdin without ERR_UNKNOWN_ENCODING: Unknown encoding: buffer and requires regression coverage. The diff changes `runProcessSync… Update the Chrome key-import error handling to preserve and report the subprocess cause, and distinguish OS-permission or unsupported-encryption failures from the programming error. Add focused regression coverage for the error mapping.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: allowing string stdin in the synchronous process runner.
Description check Passed The description is complete and relevant. It explains the user impact, technical cause, fix, rationale, linked issue, testing, limitations, cross-platform considerations, and checklist status. It also…
Out of Scope Changes check Passed The two changed files are limited to runProcessSync and its regression test. The encoding: null change directly fixes the subprocess failure in [#27617]. The string-stdin test supports that object…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.

Full details: Linked Issues check

Explanation

Direct issue [#27617] requires the synchronous helper to accept string stdin without ERR_UNKNOWN_ENCODING: Unknown encoding: buffer and requires regression coverage. The diff changes runProcessSync to use encoding: null and adds a Unicode string-stdin echo test, so those requirements are met. The issue also requires later OS-permission or unsupported-encryption failures to be reported accurately. The PR leaves the generic “OS may have denied access” handling unchanged and adds no test or implementation for that requirement.


  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor

Superseded by merged PR #28225. The fix is now on main, and your contribution is credited in the merged commit through its Co-authored-by footer.

@nwparker nwparker closed this Oct 14, 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.

[Bug]: Chrome cookie import still fails on Windows in 1.4.224: ERR_UNKNOWN_ENCODING buffer

2 participants