Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATAL undefined undefined Error: Network Error (Android) #5774

Open
Liptor opened this issue Jul 12, 2023 · 0 comments
Open

FATAL undefined undefined Error: Network Error (Android) #5774

Liptor opened this issue Jul 12, 2023 · 0 comments
Labels
priority::low A low priority issue

Comments

@Liptor
Copy link

Liptor commented Jul 12, 2023

Describe the bug

After updating react-native in the application to version 0.71.1 and targetSDK to version 33, a problem began to appear when loading pictures. Moreover, the loading is strange, the first picture does not go away, an error comes. Following it, I send the next one - the picture is sent without problems. I noticed that the bug is observed on Android versions below 12 (tested on this device)

The image is attached to formData and sent as a POST request to the server. Memo used, used the XMLHttpRequest class separately. Flipper is not used in the project, so many of the upgrade tips are out of date.
It is not an issue with the API.

Screenshot 2023-07-12 at 16 24 00

To Reproduce

No response

Code snippet

const xhrRequest = (data) => {
  const { accessToken, fileName, type, uri } = data
  const xhr = new XMLHttpRequest()
  const body = new FormData()

  xhr.open('POST', `${URL}${ENDPOINTS.ATTACH_FILE}`)
  xhr.setRequestHeader('Authorization', `Bearer ${accessToken}`)
  xhr.setRequestHeader('Content-type', 'multipart/form-data')
  body.append('file', { uri, name: fileName, type })

  xhr.send(body)
}

export const attachFile = ({ accessToken, fileName, type, uri }) => {
  const body = new FormData()
  body.append('file', {
    name: fileName,
    uri: Platform.OS === 'android' ? uri : uri.replace('file://', ''),
    type,
  })

  if (Platform.OS === 'android') {
    xhrRequest({accessToken, fileName, type, uri})
  }

  return api
    .post(ENDPOINTS.ATTACH_FILE, body, {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        'Content-type': 'multipart/form-data',
      },
      maxContentLength: Infinity,
    })
    .then(R.prop('data'))
}

Expected behavior

No response

Axios Version

0.24.0

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

18.16.1

OS

No response

Additional Library Versions

react: 18.2.0,
react-native: 0.71.10

Additional context/Screenshots

No response

@Liptor Liptor changed the title FATAL undefined undefined Error: Network Error FATAL undefined undefined Error: Network Error (Android) Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority::low A low priority issue
Projects
None yet
Development

No branches or pull requests

3 participants