-
Notifications
You must be signed in to change notification settings - Fork 353
fix: resolve issue #622 - periodic tasks running at incorrect frequencies #628
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
Conversation
…cies BREAKING CHANGE: Separate ExistingWorkPolicy and ExistingPeriodicWorkPolicy enums - registerPeriodicTask now requires ExistingPeriodicWorkPolicy instead of ExistingWorkPolicy - This mirrors Android's native WorkManager API design for better type safety Changes: - Change default periodic work policy from KEEP to UPDATE - UPDATE policy ensures new task configurations replace existing ones - Add comprehensive documentation with upstream Android links - Update example app with periodic task demo using UPDATE policy - Update all packages to use the new separated policy types Fixes #622 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
To view this pull requests documentation preview, visit the following URL: docs.page/fluttercommunity/flutter_workmanager~628 Documentation is deployed and generated using docs.page. |
- Add build_runner dependency to workmanager package - Fix .mocks.dart generation with proper ExistingPeriodicWorkPolicy types - Update generated mocks to reflect new API separation - Clean up documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…mand - Add new GitHub Actions workflow to ensure generated files are up-to-date - Create parent 'generate' command that runs both pigeon and dart generation - Update generate:pigeon to use --depends-on filter for consistency - Workflow fails PR builds if generated files are not committed This ensures the repository always contains current generated files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update example and platform interface pubspec files - Ensure version consistency across packages 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
The build.yaml file is not needed as mockito automatically discovers test files with @GenerateMocks annotations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes issue #622 where periodic tasks on Android were running at incorrect frequencies when re-registered with different intervals. The solution introduces a separate ExistingPeriodicWorkPolicy enum and changes the default policy from KEEP to UPDATE to ensure new task configurations replace existing ones.
- Separate
ExistingWorkPolicyandExistingPeriodicWorkPolicyenums for better type safety - Change default periodic work policy from
KEEPtoUPDATEto fix frequency persistence issue - Update all platform implementations to use the new enum type consistently
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| workmanager_platform_interface/pigeons/workmanager_api.dart | Added new ExistingPeriodicWorkPolicy enum with comprehensive documentation |
| workmanager_platform_interface/lib/src/workmanager_platform_interface.dart | Updated method signature to use ExistingPeriodicWorkPolicy |
| workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkManagerUtils.kt | Changed default policy to UPDATE and updated mapping function |
| workmanager/lib/src/workmanager_impl.dart | Updated method signature to match platform interface |
| example/lib/main.dart | Added demonstration of UPDATE policy with frequency selection |
Comments suppressed due to low confidence (2)
workmanager_platform_interface/pubspec.yaml:19
- Removing flutter_test dependency from dev_dependencies may break existing development workflows or CI/CD pipelines that depend on it for testing. Consider if this removal is intentional and necessary.
dev_dependencies:
example/pubspec.yaml:21
- Removing flutter_test dependency from the example app's dev_dependencies may prevent running tests for the example. This could impact the ability to validate example functionality through automated testing.
flutter_lints: ^6.0.0
- Fix type error in workmanager_integration_test.dart - Use ExistingPeriodicWorkPolicy instead of ExistingWorkPolicy for periodic tasks - Add 'dart analyze' to pre-commit checklist to catch code errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
This PR fixes issue #622 where periodic tasks on Android were running at incorrect frequencies when re-registered with different intervals.
Fixes #622
Problem
When developers register a periodic task multiple times with the same unique name but different frequencies (common during development), the original task frequency persists due to the default
ExistingPeriodicWorkPolicy.KEEPbehavior.Example scenario:
Solution
Changed default policy from
KEEPtoUPDATEfor periodic tasksUPDATEpolicy ensures new configurations replace existing onesREPLACE- doesn't cancel running workersBREAKING: Separated
ExistingWorkPolicyandExistingPeriodicWorkPolicyenumsregisterPeriodicTasknow requiresExistingPeriodicWorkPolicyChanges
UPDATEinWorkManagerUtils.ktExistingPeriodicWorkPolicyenum in Pigeon APITesting
Breaking Change
Before:
After:
This is a well-justified breaking change that improves API clarity and prevents developer confusion.
🤖 Generated with Claude Code