feat: httpStream - #2841
Conversation
Greptile SummaryThis PR adds a Cordova-backed HTTP streaming API that exposes native response bytes as a WHATWG ReadableStream, including cancellation and backpressure controls.
Confidence Score: 4/5The PR needs an upper bound for chunkSize before merging because a valid API call can exhaust native memory. The new bridge passes an unrestricted positive chunkSize into a Java byte-array allocation, and the resulting OutOfMemoryError bypasses the implementation's Exception-based stream failure and cleanup path. Files Needing Attention: src/plugins/system/android/com/foxdebug/system/StreamHttp.java, src/plugins/system/android/com/foxdebug/system/System.java Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant JS as System.httpStream
participant Bridge as Cordova bridge
participant Native as StreamHttp
participant Server
Caller->>JS: httpStream(url, options)
JS->>Bridge: http-stream-start(requestId, url, options)
Bridge->>Native: Start background request
Native->>Server: HttpURLConnection request
Server-->>Native: Status, headers, body bytes
Native-->>JS: headers event
JS-->>Caller: Resolve Response
loop Response data
Native-->>JS: Base64 data event
JS-->>Caller: Uint8Array chunk
end
JS->>Native: pause/resume/cancel
Native-->>JS: complete or error
Reviews (1): Last reviewed commit: "feat: httpStream" | Re-trigger Greptile |
| : connection.getInputStream(); | ||
| if (stream == null) { | ||
| stream = connection.getInputStream(); | ||
| } |
There was a problem hiding this comment.
Unbounded native buffer allocation
When a caller supplies a very large positive chunkSize, this line uses it directly for a native byte-array allocation, causing an OutOfMemoryError that bypasses the Exception handler and can terminate the application process. Validate or cap chunkSize before allocating the buffer.
Closes #2827