<commit_before>console.log('Service worker waking up! 😴 ');

self.addEventListener('install', event => {
  console.log('Service worker installed! 👍');
});

self.addEventListener('activate', event => {
  console.log('Service worker activated! 😁');
});

self.addEventListener('fetch', event => {
  const path = event.request.url.split('http://localhost:8081')[1];
  console.log('Intercepted request for:', path);

  if (path === '/images/sad.jpg') {
    console.log('Responding with tired.jpg instead of sad.jpg');
    event.respondWith(
      fetch('/images/tired.jpg')
    );
  }

  // event.respondWith(
  //   caches.open('my-cache').then(cache => {
  //     return cache.match(event.request)
  //       .then(response => {
  //         const fetchPromise = fetch(event.request)
  //           .then(networkResponse => {
  //             cache.put(event.request, networkResponse);
  //             return networkResponse;
  //           });
  //         return response || fetchPromise;
  //       });
  //   })
  // );
});
<commit_msg>fix(demos/sw-debug): add promise chain bug<commit_after>console.log('Service worker waking up! 😴 ');

self.addEventListener('install', event => {
  console.log('Service worker installed! 👍');
});

self.addEventListener('activate', event => {
  console.log('Service worker activated! 😁');
});

self.addEventListener('fetch', event => {
  const path = event.request.url.split('http://localhost:8081')[1];
  console.log('Intercepted request for:', path);

  if (path === '/images/sad.jpg') {
    console.log('Responding with tired.jpg instead of sad.jpg');
    event.respondWith(
      fetch('/images/tired.jpg')
    );
  }

  // event.respondWith(
  //   caches.open('my-cache').then(cache => {
  //     cache.match(event.request)
  //       .then(response => {
  //         const fetchPromise = fetch(event.request)
  //           .then(networkResponse => {
  //             cache.put(event.request, networkResponse);
  //             return networkResponse;
  //           });
  //         return response || fetchPromise;
  //       });
  //   })
  // );
});

{'fraction_non_alphanumeric': 0.18446139180171592, 'fraction_numerical': 0.004766444232602479, 'mean_word_length': 2.545608108108108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5269131', 'n_tokens_mistral': 646, 'n_tokens_neox': 629, 'n_words': 109}