MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / checkValidServiceWorker

Function checkValidServiceWorker

packages/ui/src/serviceWorker.js:64–87  ·  view source on GitHub ↗
(swUrl, config)

Source from the content-addressed store, hash-verified

62}
63
64function checkValidServiceWorker(swUrl, config) {
65 // Check if the service worker can be found. If it can't reload the page.
66 fetch(swUrl, {
67 headers: { 'Service-Worker': 'script' }
68 })
69 .then((response) => {
70 // Ensure service worker exists, and that we really are getting a JS file.
71 const contentType = response.headers.get('content-type')
72 if (response.status === 404 || (contentType != null && contentType.indexOf('javascript') === -1)) {
73 // No service worker found. Probably a different app. Reload the page.
74 navigator.serviceWorker.ready.then((registration) => {
75 registration.unregister().then(() => {
76 window.location.reload()
77 })
78 })
79 } else {
80 // Service worker found. Proceed as normal.
81 registerValidSW(swUrl, config)
82 }
83 })
84 .catch(() => {
85 console.info('No internet connection found. App is running in offline mode.')
86 })
87}
88
89export function register(config) {
90 if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {

Callers 1

registerFunction · 0.85

Calls 4

registerValidSWFunction · 0.85
unregisterMethod · 0.65
catchMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected