Store icon indicating copy to clipboard operation
Store copied to clipboard

[BUG] After a few network disabled errors next events are not being collected in stream

Open mzielu opened this issue 3 years ago • 7 comments

Describe the bug

When there is an active stream collecting events and we want to refresh data quickly a few times with the network disabled we are causing the flow to break and stop delivering events.

I have investigated the problem a little bit in the code and my guess is that flow inside newDownstream inside Multicaster class is being finished/completed/canceled unexpectedly after a few StoreResponse.Error emissions, then new Multicaster via RefCountedResource create field is being recreated, new channels are being created as well and that is why events are not delivered to the stream anymore.

To Reproduce

Steps to reproduce the behavior:

  1. Turn off plane mode/disable network connection.
  2. Launch the app.
  3. Click the refresh button couple of times.
  4. Events are not delivered to the stream after a few refresh attempts.

Another way to Reproduce

  1. Launch the app.
  2. Make a couple of successful attempts with a network-enabled connection by clicking on the refresh button.
  3. Turn off plane mode/disable network connection.
  4. Click the refresh button couple of times.
  5. Events are not delivered to the stream after a few refresh attempts.

Expected behavior

The stream should collect all the events even if they are occurring very fast and even if they are only network disabled errors.

Screenshots

I have created a sample app. I can additionally paste a recorded video here: video_with_issue

Smartphone (please complete the following information):

  • Device: Pixel 6 (real device), also many AS emulators
  • OS: Android 12 (API 31)
  • Store Version: 4.0.5

Additional context

The issue is recreated in the sample app here.

mzielu avatar May 09 '22 21:05 mzielu

I have exactly the same problem :( any updates?

radzio avatar May 13 '22 09:05 radzio

any updates?

mzielu avatar Jun 22 '22 07:06 mzielu

@KevCron

digitalbuddha avatar Jul 15 '22 12:07 digitalbuddha

Haven't solved this issue but I do have an additional detail:

The number of refreshes doesn't matter, it's the speed between them. I can get to

Events delivered to initial stream: 20
Refresh click events: 17

(and assumedly higher) consistently as long as I give enough time between clicking the "refresh" button. It's only when I click the refresh rapidly that the stream breaks.

I can see in the description @mzielu already noticed this, but if this gives anyone additional ideas on the source of the bug that would be helpful.

KevCron avatar Jul 16 '22 23:07 KevCron

Hi, I have exactly the same problem, i have investigated and found this in Multicaster. if problem occurs, there is undelivered element in channel (on line where is Channel constructor, can be defined onUndeliveredElement callback), after that, channelManager.removeDownstream(channel) throws ClosedSendChannelException for every removed channel..

Maybe this is expected behavior, but i never seen this when everything works.

lukisk avatar Aug 02 '22 21:08 lukisk

Good find! Do you happen to see why the element is undeliverable?

digitalbuddha avatar Aug 02 '22 21:08 digitalbuddha

i have no idea

lukisk avatar Aug 03 '22 05:08 lukisk