GithubHelp home page GithubHelp logo

Background sync and React about workbox HOT 4 CLOSED

NistrumCain avatar NistrumCain commented on June 11, 2024
Background sync and React

from workbox.

Comments (4)

deshaXii avatar deshaXii commented on June 11, 2024

i can fix iit

from workbox.

NistrumCain avatar NistrumCain commented on June 11, 2024

OK so i have managed to push though and get workbox set up at its core but now i am to the meat of the issue!

I need to use the backgroud sync function and i have used the example code used in the docs (see below)

My issue now is i get "Queue.js:341 Uncaught TypeError: Cannot use 'in' operator to search for 'sync' in undefined" as an error, am i missing a step?

/* eslint-disable no-undef */
import {precacheAndRoute} from 'workbox-precaching';
import {BackgroundSyncPlugin} from 'workbox-background-sync';
import {registerRoute} from 'workbox-routing';
import {NetworkOnly} from 'workbox-strategies';

const bgSyncPlugin = new BackgroundSyncPlugin('myQueueName', {
    maxRetentionTime: 24 * 60, // Retry for max of 24 Hours (specified in minutes)
  });

  registerRoute(
    /\/user/,
    new NetworkOnly({
      plugins: [bgSyncPlugin],
    }),
    'POST'
  );

precacheAndRoute(self.__WB_MANIFEST || [])  /* eslint-disable-line no-restricted-globals */;

// eslint-disable-next-line
self.addEventListener('install', event => event.waitUntil(self.skipWaiting()));
// eslint-disable-next-line
self.addEventListener('activate', event => event.waitUntil(self.clients.claim()));

from workbox.

NistrumCain avatar NistrumCain commented on June 11, 2024

It very specifically seems to be when creating the Queue its self, the issue seems to be that self.registration doesn't seem to contain the sync prop... i can see it within the registration its self

at the moment i an trying to enforce it running after the registration, which while it prevents a breaking error still isnt working

you can see below how i am enforcing the check

if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/service-worker.js').then(registration => {
      console.log('SW registered: ', registration);
    }).then(() => {
      if(navigator.serviceWorker.ready) {
        const queue = new Queue('myQueueName');
    console.log("queue", queue)
      }
    
    })
    .catch(registrationError => {
      console.log('SW registration failed: ', registrationError);
    });
  });
  
}```

from workbox.

tomayac avatar tomayac commented on June 11, 2024

Hi there,

Workbox is moving to a new engineering team within Google. As part of this move, we're declaring a partial bug bankruptcy to allow the new team to start fresh. We realize this isn't optimal, but realistically, this is the only way we see it working. For transparency, here're the criteria we applied:

Thanks, and we hope for your understanding!
The Workbox team

from workbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.