[Claimed #3463] fix(cli): decode daemon replies as streaming UTF-8
Mirrored from external contributor PR #3463 after approval by @shrey150.
Original author: @harjothkhara
Original PR: https://github.com/browserbase/stagehand/pull/3463
Approved source head SHA: 25129a98aef616b9faf9b2b5a20abf2ec74b11fb
@harjothkhara, please continue any follow-up discussion on this mirrored PR. When the external PR gets new commits, this same internal PR will be marked stale until the latest external commit is approved and refreshed here.
Original description
why
Fixes #3462. The browse CLI prints � instead of non-ASCII page text when a large daemon reply arrives in several socket chunks and a chunk boundary falls inside a multi-byte character. The client decoded each chunk on its own with chunk.toString().
what changed
packages/cli/src/lib/driver/daemon/client.ts: callsocket.setEncoding("utf8")so Node decodes across chunk boundaries, and append the string chunk.- New test
packages/cli/tests/daemon-client-decoding.test.ts: a real unix-socket fake daemon writes one reply split inside the 3-byte日. - Changeset:
browsepatch.
test plan
- New test fails on
main('���本語 ✓'instead of'日本語 ✓') and passes with the fix. packages/cli: format check, oxlint, typecheck, and the full vitest suite afterpnpm build(582 tests) pass.- Repo-wide
just check/just testnot run; checks above are scoped topackages/cli.
🤖 Generated with Claude Code
Summary by cubic
Fixes #3462: the browse CLI printed � instead of non-ASCII page text when a large daemon reply arrived across socket chunks and a chunk boundary fell inside a multi-byte character. The daemon client now calls socket.setEncoding("utf8") so Node decodes across chunk boundaries instead of decoding each chunk separately.
- Adds a test with a real unix-socket fake daemon that splits a reply inside the 3-byte
日. - Adds a
browsepatch changeset.