Skip to content

[BUG] Sync stops after Network switch #4381

Open

Description

@the-hotmann

Describe the bug

When the network switches from WiFi to mobile while syncing, the syncing process will stop and needs to be manually started again to continue. This is not appreciated; it should resume automatically.

Steps to reproduce

  1. Start syncing.
  2. Switch networks.
  3. Realize it has stopped.

Expected behavior

If the network I switched to is set/allowed to sync, it should resume automatically.

Actual behavior

It stops and needs to be resumed manually.

Details

$ /usr/bin/ocis version
Version: 5.1.0-prealpha+52b00b116
Compiled: 2024-04-10 00:00:00 +0000 UTC

Activity

  1. micbar commented on Apr 11, 2024

    @micbar
    Contributor

    @TheOneRing @dragotin

    can you help to gather the needed info? What could trigger that?

  2. TheOneRing commented on Apr 12, 2024

    @TheOneRing

    @the-hotmann which client are you using?

  3. the-hotmann commented on Apr 12, 2024

    @the-hotmann
    Author

    @micbar @TheOneRing thanks for the swift response!

    I use the android client from the PlayStore in the latest version 4.2.1 (a41d1f917)

  4. transferred this issue fromowncloud/ocison Apr 12, 2024
  5. jesmrec commented on Apr 12, 2024

    @jesmrec
    Member

    Thanks for reporting, will take a look inside. Connection is detected as lost in the middle of network switching and not resumed. In fact, connections are only resumed in case of connection recovery after outage.

  6. the-hotmann commented on Apr 13, 2024

    @the-hotmann
    Author

    @jesmrec you're welcome!
    Can you please leep this thread up-to-date and inform us about your findings and eventual changes?

    Thanks in advance!

  7. jesmrec commented on Apr 15, 2024

    @jesmrec
    Member

    Sure. At this point, we'll need to check how deep the changes would be... but it deserves a look.

  8. added this to the 4.3 - Current milestone on Apr 19, 2024
  9. self-assigned this
    on Aug 27, 2024
  10. Aitorbp commented on Sep 4, 2024

    @Aitorbp
    Contributor

    We have an operating system restriction that causes the worker to be relaunched when it meets the requirements it has. In our case, it has a restriction to only execute if there is an internet connection. When we switch connections (from Wi-Fi to cellular), the operating system decides if there is a violation of the worker’s rules, as it might interpret this specific situation as a loss of connection rather than a network change. In any case, it is something beyond our control as it depends on the operating system.

    As a potential solution, we could include a manual retry in the worker’s catch block that only works when there is an active network and a NetworkErrorException has occurred. This way, when a network change occurs, the upload would be retried.

    However, this would not completely solve the problem, as this condition might not be met for the following reason:

    • There is a network change, but the process was not fast enough for the network validation function to detect that a network is available. Therefore, it will detect that there is no connection. This issue is arbitrary because it depends on the speed at which the device connects to the network.

    This possible solution would only work for workers: uploads and downloads. All other synchronization operations must be handled separately.

    On the other hand, we have a problem with the download worker. When we lose the connection, we receive a NoNetworkConnectionException() error when we should receive a NetworkErrorException(). As a result, in this case, we cannot differentiate a priori whether the cause of the error was a server failure or a loss of connection.

  11. linked a pull request that will close this issueSync stops after Network switch #4476on Sep 23, 2024
  12. modified the milestones: 4.5 - Current, Backlog on Feb 7, 2025
  13. changed the title [-]Sync stops after Network switch[/-] [+][BUG] Sync stops after Network switch[/+] on May 19, 2026
  14. added this to the Backlog milestone on May 19, 2026
  15. DeepDiver1975 commented on Jun 30, 2026

    @DeepDiver1975
    Contributor

    Still reproducible on current master. The transfer workers have no network-switch resume path:

    • UploadFileFromFileSystemWorker.kt:121-125 — catch (throwable) { ... Result.failure() }. Any throwable (incl. a connectivity drop during a WiFi↔mobile switch) returns failure, never retry, so WorkManager won't re-run the upload on network recovery.
    • DownloadFileWorker.kt:282-285 — only NoConnectionWithServerException maps to Result.retry(); every other throwable → Result.failure(). A network-switch error not of that exact type stops without retry.

    This matches @Aitorbp's Sept-2024 analysis: returning Result.retry() for connectivity-class exceptions (when a network is/again available) would let WorkManager resume on the network change, but the worker can't reliably distinguish "connection lost" from "server error" — download surfaces NoNetworkConnectionException where NetworkErrorException is expected. The exception-classification gap is the prerequisite fix; the retry mapping depends on it.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions