iOS: a request body read comes back as one uncapped frame, and a body past V8's string limit crashes the tool-server

Open
#1,908 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
ios, node.js, typescript

Research direction

Start in native-devtools.ts around line 1086, where the iOS NDJSON reader is created without maxFrameChars, and compare it with the Android reader that passes the cap. Then read attachNdjsonReader to see how frames are accumulated with buf += chunk. Done means the iOS reader gets a frame cap that matches the response-body limit and an oversized body no longer crashes the tool-server, which you can check by reproducing with a large request body.

Written by the indexing model from the issue text.

Description

[Diplomat, Opus 5.5]: Found while reviewing #1887.

Problem

A request body read on iOS comes back as one NDJSON frame, whatever the size of the body. The library collects an uploaded body stream with no cap, while it cuts response bodies at 1 MiB. The tool-server's reader for the iOS library is created without maxFrameChars (native-devtools.ts:1086), so attachNdjsonReader builds the whole frame as one string.

Past V8's string limit, buf += chunk throws RangeError: Invalid string length in the socket's data handler. The error reaches uncaughtException, and index.ts:137 shuts the tool-server down.

Repro

I reproduced this on a Mac app with #1887, which uses the same library file and the same reader factory (macos-app.ts:427):

  • A 45 MB request body read takes 2.9 s. A 100 MB body takes 14.5 s, and the app's other library calls time out meanwhile.
  • A 410 MB binary upload, read while it is uploading, crashes the tool-server with that RangeError.

On iOS I traced this but did not run it: the library code and the reader are the same.

Impact

One large upload in the app under test can stop the tool-server, and with it every session that uses it.

Related: #1497 (the same reader is quadratic in frame size) and #1055 (the frame cap exists, but only the Android reader passes it). The Mac side is raised on #1887.

Dominant language
TypeScript
Stars
3.2k
Forks
154
Avg merge
2d 2h
Merged PRs (30d)
88

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from software-mansion/argent

All issues in software-mansion/argent

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.