Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
Is there any synchronous (non-async) storage API for background service worker in Chrome Extension Manifest V3?

We are in process of upgrading many Chrome extensions to Manifest version 3. Many of them has a background script that use localStorage which is not available in Service Worker. I know chrome.storage or IndexedDB APIs are valid replacement but they are asynchronous and it would takes a lot of effort for some extensions to be changed into async. So my problem can be solved by either:

  • Find a storage API that is NOT async which I am not aware of.

  • Question: Find a pattern that can quickly and reliably upgrade synchronous code in many places into asynchronous.

I believe the 2nd attempt is the most sensible one. However so many places have methods like this (just example) which makes upgrading difficult and also prone to error due to missing Promise/await.

// Background
localStorage["key"] = true;

if (localStorage["key2"]) {
    // Do stuff
}

// Foreground/Popup/Content Script
if (localStorage["key"]) { /* Do Something */ }
if (localStorage["key2"]) { /* Do Something Else */ }
localStorage["key3"] = "My Value";

There are a few nice extensions with these code, which are easy to upgrade:

chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
    if (request.method == "getLocalStorage") {
        sendResponse({ data: localStorage[request.key] });
    }
});

Which I simply need to change the message handler to async since the receiving end is already callback-based. Unfortunately, every extension is very different and there is no standard way of doing it.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda