react-native-blob-util icon indicating copy to clipboard operation
react-native-blob-util copied to clipboard

Not getting headers , status , respType , redirects in the respInfo of response occasionally in iOS.

Open rifad4u opened this issue 1 year ago • 37 comments

Not getting headers , status , respType , redirects in the respInfo of response occasionally in iOS. on that time getting "rnfbEncode" only in the respInfo.

i'm attaching 2 screenshots here , both screenshots are responsible for same api and getting the same data in the data part , but the respInfo are not getting properly. Screenshot 2023-03-22 at 2 42 24 PM Screenshot 2023-03-22 at 2 42 53 PM

rifad4u avatar Mar 22 '23 09:03 rifad4u

I'm experiencing this as well. It seems to happen more often on fresh installations of an app.

It seems like the event which sets the responsive info isn't being received by the JS.

From my debugging with adding logging throughout the code, it seems like this event is being dispatched: https://github.com/RonRadtke/react-native-blob-util/blob/master/ios/ReactNativeBlobUtilRequest.mm#L272-L282

But it is not being received in the JS code which ultimately sets the response info: https://github.com/RonRadtke/react-native-blob-util/blob/master/fetch.js#L203-L207

It seems like the HTTP request is successful, as I can see a 200 status being logged, but the JS layer isn't able to report the successful state of the download back to the code which initiated the request.

cjpete avatar Mar 27 '23 20:03 cjpete

hi @RonRadtke, can you check this please? Getting only rnfbEncode in respInfo quite often recently

kelly-torum avatar Apr 03 '23 11:04 kelly-torum

I'm using a workaround which checks that the response is exactly that, and the platform is IOS. Then check if the file exists and is of non-zero size.

if (Platform.OS === 'ios' && JSON.stringify(response.respInfo) === JSON.stringify({rnfbEncode: 'path'})) {
  // check file exists and has non-zero size 
  // if so, treat as successful operation

cjpete avatar Apr 03 '23 14:04 cjpete

respInfo

In my case i want to check for the status of the response. for now i have downgraded to 0.17.1 and i haven’t faced this issue with this version.

rifad4u avatar Apr 03 '23 14:04 rifad4u

How do you get the proper response header on iOS?

kelly-torum avatar Apr 03 '23 14:04 kelly-torum

How do you get the proper response header on iOS?

Use 0.17.1th version

rifad4u avatar Apr 03 '23 17:04 rifad4u

Use 0.17.1th version

@rifad4u I'm using 0.17.1 version. do you any other workarounds to get response headers? @RonRadtke @cjpete 😓

kelly-torum avatar Apr 04 '23 03:04 kelly-torum

Are you using libraries like RNN or maybe two navigators (button tabs + stack) or so? I could imagine that there are problems if the root view can't be accessed and therfor the bridge might be null. That could ultimatley lead to events not being sent to JS correctly.

RonRadtke avatar Apr 04 '23 18:04 RonRadtke

@RonRadtke Then y this issue is happening occasionally only, if that is the case then it should happen every time , right?

rifad4u avatar Apr 04 '23 18:04 rifad4u

@rifad4u that's right, except if you're changing navigators somewhen during the life cycle.

But I honselty don't have a better idea right know either. I might be solved once I rewrote the whole vent system to a newer and hopefully more stable system using modern APIs / classes

RonRadtke avatar Apr 04 '23 18:04 RonRadtke

@RonRadtke in my case i'm facing this while opening the application only , not happening in between and it is not replicating if i close and relaunch the application.

rifad4u avatar Apr 04 '23 18:04 rifad4u

@rifad4u it sounds wired as a behaviour. I'm sorry but I currently don't have an explanation for it. If you have the chance it would be great to try to debug it, I can't reproduce it in my app yet. Would be good to know if the bridge / eventDispatcher are set up correctly or if these are not set correctly. And if not, why...

RonRadtke avatar Apr 04 '23 18:04 RonRadtke

Hi @RonRadtke,

We have the same issue on our side. We use react-native-navigation.

After some tests, I can track the issue from this change => https://github.com/RonRadtke/react-native-blob-util/commit/6290b21c3b5e60626a19bb6ea43f1579e15a8626

It's seem like:

  • rootView.bridge.eventDispatcher => can cause some crash at startup (we had them when we was on 0.70.1)
  • bridge.eventDispatcher; => is not reliable & can lost some events

I will try to set up some minimal reproduction.

~In our app we have multiple navigator & use react-native-blob-util in different places. This could explain that react-native-blob-util can keep an incorrect ref to the bridge ?~ I tried to use react-native-blob-util only in one place without success

gkueny avatar Apr 05 '23 08:04 gkueny

We're having the exact same issue on 0.17.3. Downgrading to 0.17.1 fixes the issue for us.

timjbray avatar Apr 05 '23 22:04 timjbray

~~I managed to reproduce it now in a local app but unsure yet how to fix it~~

RonRadtke avatar Apr 06 '23 18:04 RonRadtke

Had the same issue and downgrading to 0.17.1 worked for me as well

matthewmturner avatar Apr 09 '23 02:04 matthewmturner

@cjpete could you test if the eventDispatcher is set and maybe if you get a bridge in https://github.com/RonRadtke/react-native-blob-util/blob/132051c1204051f5148a0b4bfede00ed99f47c44/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm#L71 ? Sadly my repro for reproduction was a fail and I'm still struggling to reproduce it....

RonRadtke avatar Apr 12 '23 20:04 RonRadtke

Same issue :(

zfrankdesign avatar May 04 '23 16:05 zfrankdesign

Any new Informationen? Anyone? Could it be that it only happens when the appnis in the background or any idea based on yours app usage pattern? I'm currently rewriting the whole event handling structure but i would feel better about it if i know where the problem currently is

RonRadtke avatar May 07 '23 07:05 RonRadtke

@RonRadtke, we do experience the same issue on 0.17.3 and we send multipart/form-data to the Java backend. It happens when the app is in the foreground and can be reproduced both on the device and the simulator. We tried on devices with ios versions 16.2 and 15.7, but an android app was working well. There are no clear steps to reproduce the issue, because it may work properly and in an hour accidentally stop working on the same device with the same data.

env: [email protected] "react-native-navigation": "^7.32.1" "@reduxjs/toolkit": "^1.9.3" "react": "18.1.0"

Hope this helps

emelyanova avatar May 08 '23 20:05 emelyanova

Hi RonRadtke/react-native-blob-util,

This issue is happening when the app opens for the first time or opens from killed state , not happening this issue in between. means if you get proper response when the app opens then this issue won’t come in this session.

On Sun, May 7, 2023 at 1:11 PM Ron Radtke @.***> wrote:

Any new Informationen? Anyone? Could it be that it only happens when the appnis in the background or any idea based on yours app usage pattern? I'm currently rewriting the whole event handling structure but i would feel better about it if i know where the problem currently is

— Reply to this email directly, view it on GitHub https://github.com/RonRadtke/react-native-blob-util/issues/236#issuecomment-1537347176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI3JTW6CDEBIRO5QHLGIFJTXE5G27ANCNFSM6AAAAAAWDRDZBY . You are receiving this because you were mentioned.Message ID: @.***>

rifad4u avatar May 09 '23 11:05 rifad4u

@rifad4u @emelyanova Thank you for the information. Could you try to remove /comment out this line: https://github.com/RonRadtke/react-native-blob-util/blob/132051c1204051f5148a0b4bfede00ed99f47c44/index.js#L45 And see if youbstill can reproduce it? I so far didn't manage to reproduce it at allregardless how often i try

RonRadtke avatar May 11 '23 16:05 RonRadtke

emitExpiredEvent

Screenshot 2023-05-12 at 7 07 27 AM

Commented the line , but still facing the same issue 😕.

rifad4u avatar May 12 '23 01:05 rifad4u

Too bad 😕 @rifad4u I assume you can't create an example repo for reproducing it either? But I hope I get the new event emitting rework for ios done next week or the week after. Maybe you could test if that helps once I'm done?

RonRadtke avatar May 12 '23 05:05 RonRadtke

Too bad 😕 @rifad4u I assume you can't create an example repo for reproducing it either? But I hope I get the new event emitting rework for ios done next week or the week after. Maybe you could test if that helps once I'm done?

I'm trying to reproduce the same in a new project. meanwhile if you apply any fix you can comment here , i will check.

rifad4u avatar May 12 '23 05:05 rifad4u

Thank you. Otherwise what could be interesting is if you have an eventdispatcher in this line or if it is e.g. null. So basically if the issue is somewhere there of in js https://github.com/RonRadtke/react-native-blob-util/blob/132051c1204051f5148a0b4bfede00ed99f47c44/ios/ReactNativeBlobUtilRequest.mm#L273

RonRadtke avatar May 12 '23 05:05 RonRadtke

@rifad4u I got the ios part of the new eventemitter structure done and did a basic testing on it. you can use it by setting the version of react-native-blob-util to "ronradtke/react-native-blob-util#feature/eventemitter_rework"

Would be great if you could test if you can reproduce the issue on that branch too.

RonRadtke avatar May 22 '23 09:05 RonRadtke

@rifad4u I got the ios part of the new eventemitter structure done and did a basic testing on it. you can use it by setting the version of react-native-blob-util to "ronradtke/react-native-blob-util#feature/eventemitter_rework"

Would be great if you could test if you can reproduce the issue on that branch too.

Hi @RonRadtke , Still facing the same issue , please find the screenshots below. Screenshot 2023-05-22 at 4 40 41 PM Screenshot 2023-05-22 at 4 40 53 PM

rifad4u avatar May 22 '23 11:05 rifad4u

Both screenshots are the same request or what are you showing here? Did you check if the event is being fired within the native code?

RonRadtke avatar May 22 '23 12:05 RonRadtke

Both screenshots are the same request or what are you showing here? Did you check if the event is being fired within the native code?

First screenshot is from the fetch.js file , line no : 205 ,

Second screenshot is the response i got when i called the api.

rifad4u avatar May 22 '23 12:05 rifad4u