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

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

Open
rifad4u opened this issue Mar 22, 2023 · 37 comments

Comments

@rifad4u
Copy link

rifad4u commented Mar 22, 2023

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 rifad4u changed the title Not getting headers , status , respType , redirects in the request response occasionally in iOS. Not getting headers , status , respType , redirects in the respInfo of response occasionally in iOS. Mar 22, 2023
@cjpete
Copy link

cjpete commented Mar 27, 2023

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.

@kelly-torum
Copy link

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

@cjpete
Copy link

cjpete commented Apr 3, 2023

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

@rifad4u
Copy link
Author

rifad4u commented Apr 3, 2023

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.

@kelly-torum
Copy link

How do you get the proper response header on iOS?

@rifad4u
Copy link
Author

rifad4u commented Apr 3, 2023

How do you get the proper response header on iOS?

Use 0.17.1th version

@kelly-torum
Copy link

Use 0.17.1th version

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

@RonRadtke
Copy link
Owner

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.

@rifad4u
Copy link
Author

rifad4u commented Apr 4, 2023

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

@RonRadtke
Copy link
Owner

@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

@rifad4u
Copy link
Author

rifad4u commented Apr 4, 2023

@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.

@RonRadtke
Copy link
Owner

@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...

@gkueny
Copy link

gkueny commented Apr 5, 2023

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 => 6290b21

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

@timjbray
Copy link

timjbray commented Apr 5, 2023

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

@RonRadtke
Copy link
Owner

RonRadtke commented Apr 6, 2023

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

@matthewmturner
Copy link

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

@RonRadtke
Copy link
Owner

@cjpete could you test if the eventDispatcher is set and maybe if you get a bridge in

eventDispatcherRef = bridge.eventDispatcher;
?
Sadly my repro for reproduction was a fail and I'm still struggling to reproduce it....

@zfrankdesign
Copy link

Same issue :(

@RonRadtke
Copy link
Owner

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

@emelyanova
Copy link

@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:
react-native@0.70.6
"react-native-navigation": "^7.32.1"
"@reduxjs/toolkit": "^1.9.3"
"react": "18.1.0"

Hope this helps

@rifad4u
Copy link
Author

rifad4u commented May 9, 2023 via email

@RonRadtke
Copy link
Owner

@rifad4u @emelyanova
Thank you for the information.
Could you try to remove /comment out this line:

ReactNativeBlobUtil.emitExpiredEvent(() => {

And see if youbstill can reproduce it?
I so far didn't manage to reproduce it at allregardless how often i try

@rifad4u
Copy link
Author

rifad4u commented May 12, 2023

emitExpiredEvent

Screenshot 2023-05-12 at 7 07 27 AM

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

@RonRadtke
Copy link
Owner

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?

@rifad4u
Copy link
Author

rifad4u commented May 12, 2023

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.

@RonRadtke
Copy link
Owner

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

sendDeviceEventWithName: EVENT_STATE_CHANGE

@RonRadtke
Copy link
Owner

@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.

@rifad4u
Copy link
Author

rifad4u commented May 22, 2023

@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

@RonRadtke
Copy link
Owner

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?

@rifad4u
Copy link
Author

rifad4u commented May 22, 2023

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.

@RonRadtke
Copy link
Owner

Thank you! I committed a fix for it.
I missed a JSON.parse there..
The status code seems to be set correctly in the event that js is getting. It's set to 200. But please try again to confirm if it is working

@rifad4u
Copy link
Author

rifad4u commented May 22, 2023

Thank you! I committed a fix for it. I missed a JSON.parse there.. The status code seems to be set correctly in the event that js is getting. It's set to 200. But please try again to confirm if it is working

@RonRadtke It is working 😍 , getting proper response now.

@RonRadtke
Copy link
Owner

Great. I will try to finish the Android part this week and then hopefully get it live :)

RonRadtke pushed a commit that referenced this issue May 31, 2023
* Additional parameter for androiddownloads to enforce the downloaded file being added to the downloads collection

resolves #247
resolves #248
resolves #245
resolves #244
resolves #236

Merge branch 'develop'
@NishilE
Copy link

NishilE commented Nov 22, 2023

Hi, @RonRadtke, have you released the Android fix yet? I'm still having the same issue with version 0.19.4. The same issue happening for me as @rifad4u. I'm unable to get any responses on the first try after the app is opened. But It works when I kill the app and try again. I would be really grateful if you could give a reply as soon as possible since I'm blocked by the issue. Thank you for your effort and consideration.

@RonRadtke
Copy link
Owner

Hi, @RonRadtke, have you released the Android fix yet? I'm still having the same issue with version 0.19.4. The same issue happening for me as @rifad4u. I'm unable to get any responses on the first try after the app is opened. But It works when I kill the app and try again. I would be really grateful if you could give a reply as soon as possible since I'm blocked by the issue. Thank you for your effort and consideration.

Yes I fixed aome problems here. But it could be we're running in some race conditions here, or, some problems during registration of the event listener.

@RonRadtke RonRadtke reopened this Nov 22, 2023
@RonRadtke
Copy link
Owner

Hi, @RonRadtke, have you released the Android fix yet? I'm still having the same issue with version 0.19.4. The same issue happening for me as @rifad4u. I'm unable to get any responses on the first try after the app is opened. But It works when I kill the app and try again. I would be really grateful if you could give a reply as soon as possible since I'm blocked by the issue. Thank you for your effort and consideration.

Yes I fixed aome problems here. But it could be we're running in some race conditions here, or, some problems during registration of the event listener.

@NishilE you are facing problems on Android? The issue and fixed here are about ios...

@NishilE
Copy link

NishilE commented Nov 23, 2023

@RonRadtke, Yes I'm facing the issue on Android. I saw your comment that you will try to finish the Android part. That's why I checked here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants