Unable to construct a new Blob()
Description
After creating a React Native app with the new architecture enabled, using the global Blob() constructor resulted in the following error: Invariant Violation: NativeBlobModule is available. This was reproducible in the following combinations:
| Platform | React Native version | New architecture enabled? | Blob() available? |
|---|---|---|---|
| iOS | 0.70.3 | Yes | ❌ |
| Android | 0.70.3 | Yes | ✅ |
| iOS | 0.68.4 | Yes | ❌ |
| iOS | 0.70.3 | No | ✅ |
| Android | 0.70.3 | No | ✅ |
| iOS | 0.68.4 | No | ✅ |
As a result of this global Blob() being unavailable, the blob() method in whatwg-fetch polyfill is also now missing from Requests/Responses since the library first checks for Blob support.
Version
0.70.3, 0.68-stable
Output of npx react-native info
info Fetching system and libraries information... System: OS: macOS 12.5.1 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 2.47 GB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node Yarn: 1.22.17 - ~/.yarn/bin/yarn npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: API Levels: 28, 30, 31, 32 Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0 System Images: android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild Languages: Java: 12.0.2 - /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.3 => 0.70.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
- Create a new React Native application via the CLI
- Enable the new architecture
- Try to create a new Blob()
Snack, code example, screenshot, or link to a repository
const App = () => {
useEffect(() => {
try {
new Blob();
} catch (e) {
console.log(e); // [Invariant Violation: NativeBlobModule is available.]
}
});
return null;
};
https://github.com/facebook/react-native/pull/35047
Since the above PR was merged and reverted, can someone confirm that this is still being looked at for 0.71 per this comment by @cipolleschi ?
The right fix has been merged in 0.71 (which will be released in a few weeks). From the OSS perspective, the commit looks the same, but we have to update an internal script to properly generate those lines.
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.
This issue was closed because it has been stalled for 7 days with no activity.