Skip to content

fix: worker start not allowed exception#16038

Merged
alperozturk96 merged 2 commits into
masterfrom
fix/worker-start-not-allowed-exception
Dec 4, 2025
Merged

fix: worker start not allowed exception#16038
alperozturk96 merged 2 commits into
masterfrom
fix/worker-start-not-allowed-exception

Conversation

@alperozturk96
Copy link
Copy Markdown
Collaborator

@alperozturk96 alperozturk96 commented Dec 1, 2025

  • Tests written, or not not needed

Issue

Long-running CoroutineWorkers (like FileUploadWorker, FolderDownloadWorker) attempt to start a foreground service using setForeground() to comply with WorkManager requirements.

On some devices or Android versions, this can throw:

2025-12-01 09:32:51.500  2566-2664  FileUploadWorker  E  com.nextcloud.client
    Error caught at FileUploadWorker: 
    android.app.ForegroundServiceStartNotAllowedException: 
        startForegroundService() not allowed due to mAllowStartForeground = false
        at service com.nextcloud.client/androidx.work.impl.foreground.SystemForegroundService

2025-12-01 09:32:51.500  2566-2591  WM-GreedyScheduler  D  com.nextcloud.client
    Constraints met: Scheduling work ID WorkGenerationalId(
        workSpecId = 738d8cdc-3311-4dc3-8b3f-019043410db9, 
        generation = 0
    )

2025-12-01 09:32:51.500  2566-2664  FileUploadWorker  E  com.nextcloud.client
    FileUploadWorker stopped

Changes

Previously, this exception would fail the worker, stopping uploads/downloads unnecessarily. Instead of failing the worker, the error is logged as a warning.

Adds OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST

How to reproduce?

  1. Select a one big file (e.g. 1GB) to upload
  2. Then again select another big file to upload

Signed-off-by: alperozturk <alper_ozturk@proton.me>
@alperozturk96 alperozturk96 force-pushed the fix/worker-start-not-allowed-exception branch from b5d33e6 to 5337d84 Compare December 3, 2025 10:36
Signed-off-by: alperozturk <alper_ozturk@proton.me>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 3, 2025

Codacy

SpotBugs

CategoryBaseNew
Bad practice4243
Correctness7474
Dodgy code268268
Experimental11
Internationalization77
Malicious code vulnerability33
Multithreaded correctness3434
Performance4848
Security1818
Total495496

SpotBugs increased!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 3, 2025

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16038.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 3, 2025

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@alperozturk96 alperozturk96 merged commit b89a7dd into master Dec 4, 2025
16 of 21 checks passed
@alperozturk96 alperozturk96 deleted the fix/worker-start-not-allowed-exception branch December 4, 2025 12:15
@tobiasKaminsky tobiasKaminsky added this to the Nextcloud App 3.35.0 milestone Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants