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

295
Views
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
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!