mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary:
issue: https://github.com/facebook/react-native/issues/39441
For the following reasons, I have replaced an object used for id management inside BlobRegistry with `Map`.
- The polyfill used for `fetch`, [whatwg-fetch](https://github.com/JakeChampion/fetch), returns responses as `Blob` objects.
- When a `Blob` is created, it is registered with blobID in the [BlobRegistry](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/BlobRegistry.js), which is not automatically released.
- This issue was previously reported in https://github.com/facebook/react-native/issues/19248 and was fixed by modifying whatwg-fetch. However, with the implementation of automatic garbage collection in https://github.com/facebook/react-native/issues/24405, the implementation was reverted in commit bccc92dfdd, returning to the original behavior.
- Although https://github.com/facebook/react-native/issues/24405 enables `Blob` objects to be garbage collected, the Blob IDs registered in the BlobRegistry remain, causing the count to increase each time `fetch` is called.
- As a result, the `Property storage exceeds 196607 properties` error occurs
To address this issue, I have modified the implementation of `BlobRegistry` to use a `Map` instead of an object. By using a `Map`, there is no limit to the number of entries.
## Changelog:
[Internal] - [Fixed] - Fixed a bug that caused a "Property storage exceeds 196607 properties" error when sending a certain number of `fetch` requests.
Pull Request resolved: https://github.com/facebook/react-native/pull/39528
Test Plan:
I've added a new tests in `packages/react-native/Libraries/Blob/__tests__/BlobRegistry-test.js` and confirmed the test pass before and after changes.
```
$ yarn run test
...
Test Suites: 1 skipped, 219 passed, 219 of 220 total
Tests: 2 skipped, 4017 passed, 4019 total
Snapshots: 1154 passed, 1154 total
Time: 10.525 s
Ran all test suites.
✨ Done in 12.52s.
```
Reviewed By: javache
Differential Revision: D49423213
Pulled By: NickGerleman
fbshipit-source-id: d5f73d7f5e34d1d2c3969b7dfbc45d3e6196aa30