capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

[Bug]: CapacitorHttp seems block stream response until it's finished?

Open z-zeechung opened this issue 11 months ago • 1 comments

Capacitor Version

Capacitor Doctor

Latest Dependencies:

@capacitor/cli: 7.0.1 @capacitor/core: 7.0.1 @capacitor/android: 7.0.1 @capacitor/ios: 7.0.1

Installed Dependencies:

@capacitor/ios: not installed @capacitor/core: 6.1.2 @capacitor/android: 6.1.2 @capacitor/cli: 6.1.2

[success] Android looking great! 👌

Other API Details

npm --version
10.1.0

node --version
v20.9.0

Platforms Affected

  • [ ] iOS
  • [x] Android
  • [ ] Web

Current Behavior

I am currently working on an AI APP which invokes LLMs from web directly. To bypass CORS restriction, I use CapacitorHttp. The CapacitorHttp seems blocks all stream response before they finish. I have reproduced this problem in a minimum program.

Expected Behavior

The stream response should be returned chunk by chunk

Project Reproduction

https://github.com/z-zeechung/nnchat-capacitor-http-stream-bug-reproduce

Additional Information

No response

z-zeechung avatar Feb 15 '25 15:02 z-zeechung

Yes, it does (at least on the web). It's apparently a limitation on mobile platform: Note: On Android and iOS, data can only be a string or a JSON.. Is that true? Or, it's due to the difficulty to stream data from javascript to the native code?

yannikmesserli avatar Mar 04 '25 08:03 yannikmesserli