Skip to content

fix(cli): count socket response cap by bytes#2813

Open
mksocial19-code wants to merge 2 commits into
nanocoai:mainfrom
mksocial19-code:fix/pr-2802-byte-count
Open

fix(cli): count socket response cap by bytes#2813
mksocial19-code wants to merge 2 commits into
nanocoai:mainfrom
mksocial19-code:fix/pr-2802-byte-count

Conversation

@mksocial19-code

Copy link
Copy Markdown

Replacement for #2802.

Summary

  • Track socket response cap with accumulated Buffer byteLength before UTF-8 decoding
  • Keep buffering decoded text only after byte cap passes
  • Add regression test using multi-byte UTF-8 payload whose character length is below the cap but byte length exceeds it

Validation

  • pnpm install --frozen-lockfile
  • pnpm typecheck
  • pnpm build
  • pnpm test
  • pnpm exec eslint src/cli/socket-client.ts src/cli/socket-client.test.ts (0 errors; existing no-catch-all warnings in socket-client.ts)

Fixes byte-count issue noted on #2802.

sturdy4days and others added 2 commits June 17, 2026 15:18
SocketTransport.sendFrame has no timeout and no buffer bound. A host that
accepts the connection but never replies leaves the promise unsettled forever;
a host streaming without a newline grows the buffer without limit. Add a 30s
request timeout and a 16MB response cap (callers are interactive ncl commands).
Relates to nanocoai#2665 (host-freeze from unbounded/synchronous ops).
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.

2 participants