facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.39k stars 24.13k forks source link

WebSocket bufferedAmount is always undefined #33810

Open hrjr4433 opened 2 years ago

hrjr4433 commented 2 years ago

Description

WebSocket's bufferedAmount is always undefined. Either iOS or Android, after connecting to URL and sending data, socket.bufferedAmount is undefined.

Version

0.66.2

Output of npx react-native info

System: OS: macOS 12.1 CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz Memory: 613.17 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.3.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.19.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: System Images: android-26 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8309675 Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 1.8.0_265 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.2 => 0.66.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

  1. Initialize a WebSocket, then check bufferedAmount is undefined.
  2. Send some data, then check bufferedAmount is undefined.

Snack, code example, screenshot, or link to a repository

const sock = new WebSocket(url);

console.log(sock.bufferedAmount); // it's undefined

const data = new Uint8Array(8192); // (1<<13) = 8kBytes
sock.send(data);

console.log(sock.bufferedAmount); // it's also undefined
shankerpandey commented 1 year ago

Description

WebSocket's bufferedAmount is always undefined. Either iOS or Android, after connecting to URL and sending data, socket.bufferedAmount is undefined.

Version

0.66.2

Output of npx react-native info

System: OS: macOS 12.1 CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz Memory: 613.17 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.3.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.19.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: System Images: android-26 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8309675 Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 1.8.0_265 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.2 => 0.66.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

  1. Initialize a WebSocket, then check bufferedAmount is undefined.
  2. Send some data, then check bufferedAmount is undefined.

Snack, code example, screenshot, or link to a repository

const sock = new WebSocket(url);

console.log(sock.bufferedAmount); // it's undefined

const data = new Uint8Array(8192); // (1<<13) = 8kBytes
sock.send(data);

console.log(sock.bufferedAmount); // it's also undefined

+1

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

wuyue1019 commented 9 months ago

Still has the same issue in RN 0.71.6

I am thinking to use this bufferedAmount property to inform user of too many instructions not sent when with bad network condition. Or is there a better way to do that?