hermes icon indicating copy to clipboard operation
hermes copied to clipboard

Property storage exceeds 196607 properties when sending a file via fetch()

Open CommanderRedYT opened this issue 1 year ago • 2 comments

Bug Description

In my app I am using fetch to upload a file to a server. The server accepts the data in the same format as a HTML form would send it. I am using FormData to prepare the data. The error occurs when sending the data. This happens with axios, fetch and XMLHttpRequest. (probably because it's all the same)

Using XMLHttpRequest

image image

Using axios

image image

  • [x] I have run gradle clean and confirmed this bug does not occur with JSC
  • [x] The issue is reproducible with the latest version of React Native.

Hermes git revision (if applicable): - React Native version: 0.74.1 OS: Host: Linux, Phone: Android 12 Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86_64 (emulator)

Steps To Reproduce

  1. Create a ~2MB Uint8Array (for example a binary for OTA updating a MCU)
  2. Add it to a FormData instance
  3. Make a request

code example:

axios

const uploadOTA = async (data: Uint8Array) => {
  const formData = new FormData();
  formData.append('firmware', data);

  const axiosOptions = {
    url: 'http://localhost:3000/', // test server
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  };

  const res = await axios(axiosOptions);

  return res.status === 200;
};

uploadOTA(data); // In my code, this data is the result of a fetch request that is downloading a binary from github releases

fetch

const uploadOTA = async (data: Uint8Array) => {
  const formData = new FormData();
  formData.append('firmware', data);

  const fetchOptions: RequestInit = {
    method: 'POST',
    body: formData,
    headers: new Headers({
      'Content-Type': 'multipart/form-data',
    }),
  };

  const res = await fetch('http://localhost:3000/', fetchOptions);

  return res.status === 200;
};

uploadOTA(data); // In my code, this data is the result of a fetch request that is downloading a binary from github releases

The Expected Behavior

No crash, file uploading.

CommanderRedYT avatar May 07 '24 06:05 CommanderRedYT

Hi, unfortunately we can't debug 3rd party libraries, we need a minimal reproduction that clearly indicates what the problem in Hermes is.

In this case my recommendation is to try to understand why more than 195,000 properties are being added to a JS object. What are the names of these properties? Are they numeric?

tmikov avatar May 07 '24 20:05 tmikov

Running in to the same issue. Any tips on how to get the names of these properties to be able to debug?

RemiHin avatar May 24 '24 18:05 RemiHin

Did you fixed it?

angelopedroso avatar Oct 04 '24 19:10 angelopedroso

For me the solution was a workaround, but it's use-case specific.

Because my goal was to upload a file to a server, I just used the file upload functionality from the react-native-fs module.

CommanderRedYT avatar Oct 04 '24 22:10 CommanderRedYT