Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
cómo resolver service_worker_en.js: 3 TypeError no capturado (en promesa): ¿No se pudo ejecutar 'fetch' en 'WorkerGlobalScope'?

Mi consola Chrome está dando este error para mi sitio web

 service_worker_en.js:3 Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'WorkerGlobalScope': Cannot construct a Request with a Request object that has already been used.

He leído este artículo sobre SO pero todavía no puedo entender cuál es realmente el problema con mi código. Aquí está mi código de trabajador de servicio

 self.addEventListener("install", function(event) { event.waitUntil(preLoad()); }); var preLoad = function() { console.log("Installing web app"); return caches.open("offline").then(function(cache) { console.log("caching index and important routes"); return cache.addAll(["/", "/devotional-language-en-tab-9"]); }); }; self.addEventListener("fetch", function(event) { event.respondWith(checkResponse(event.request).catch(function() { return returnFromCache(event.request); })); event.waitUntil(addToCache(event.request)); }); var checkResponse = function(request) { return new Promise(function(fulfill, reject) { fetch(request).then(function(response) { if (response.status !== 404) { fulfill(response); } else { reject(); } }, reject); }); }; var addToCache = function(request) { return caches.open("offline").then(function(cache) { return fetch(request).then(function(response) { console.log(response.url + " was cached"); return cache.put(request, response); }); }); }; var returnFromCache = function(request) { return caches.open("offline").then(function(cache) { return cache.match(request).then(function(matching) { if (!matching || matching.status == 404) { return cache.match("offline_en.html"); } else { return matching; } }); }); };

Según Chrome, el error se encuentra principalmente en estas dos líneas:

ingrese la descripción de la imagen aquí

cómo resolver service_worker_en.js:3 Uncaught (en promesa) TypeError: ? Por favor, necesito una respuesta específica que resuelva el problema.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe clonar el objeto de solicitud antes de obtenerlo mediante API_ENDPOINT.clone() , ya que el objeto ya se ha consumido.

 var addToCache = function(request) { return caches.open("offline").then(function(cache) { return fetch(request.clone()).then(function(response) { console.log(response.url + " was cached"); return cache.put(request, response); }); }); }; ...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!