Skip to content

Fix service worker to only unregister in development mode#18

Draft
Copilot wants to merge 25 commits intomasterfrom
copilot/sub-pr-13-one-more-time
Draft

Fix service worker to only unregister in development mode#18
Copilot wants to merge 25 commits intomasterfrom
copilot/sub-pr-13-one-more-time

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 3, 2025

Service worker code was unconditionally unregistering all service workers, breaking PWA offline capabilities in production.

Changes

  • Environment detection: Check if running on localhost/127.x.x.x to determine dev vs prod
  • Conditional behavior: Unregister service workers only in development; register them in production
  • Error handling: Added .catch() for graceful handling of registration failures
if (isLocalhost) {
    // Dev: unregister to avoid caching issues
    navigator.serviceWorker.getRegistrations().then(function(registrations) {
        for(let registration of registrations) {
            registration.unregister();
        }
    });
} else {
    // Prod: register for PWA functionality
    navigator.serviceWorker.register('service-worker.js')
        .catch(function(error) {
            console.warn('Service worker registration failed:', error);
        });
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

MichaelSL and others added 23 commits December 2, 2025 18:18
- Added Replacement Pattern input and Replace button to RegexTester.
- Introduced new Replace tab to display original and replaced strings.
- Implemented GetReplacedStrings method in IRegexService and RegexService.
- Added export options for JSON, CSV, and plain text formats with download functionality.
- Enhanced UI with new buttons and improved error handling for exports.
Copilot AI and others added 2 commits December 3, 2025 03:23
Co-authored-by: MichaelSL <2205113+MichaelSL@users.noreply.github.com>
Co-authored-by: MichaelSL <2205113+MichaelSL@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback from review on net10 upgrade Fix service worker to only unregister in development mode Dec 3, 2025
Copilot AI requested a review from MichaelSL December 3, 2025 03:27
Base automatically changed from upgrade-to-NET10 to master December 3, 2025 03:42
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

Successfully merging this pull request may close these issues.

2 participants