Unexpected error occurrs when I try to acess local storage in my extension

I’m updating the extension I wrote few months ago and just when I finished I realized that local storage in loader.js (file which is loaded on each visit to the specific page) returns:

Error: "An unexpected error occurred."

It is the part where I try to load informations from the local storage:

chrome.storage.local.get('setting-one', result => {
  if (chrome.runtime.lastError) {
    throw new Error(chrome.runtime.lastError); // error is thrown

This worked without problems in the past but now it doesn’t. This is the case for Firefox. On Chrome, extension doesn’t work either and doesn’t return any error from loader.js. I’m not sure if API has changed or some new changes were introduced regarding access to local storage. I was looking for the solution on the web but there is nothing regarding this problem.

On the page of extension I can set and get all informations from storage without any problem.

How can I save data in a public storage in chrome extension?

How can I save data in a storage in chrome extension so that their friends in hangout/gmail contacts can also access that data ? Basically I am trying to create a poll based chrome extension. Is there any server side option provided by Google itself ? And Can we make use of fire base here ? Thanks in advance.

Speed of chrome.storage.sync.get vs get from chrome.storage.local

I’m developing a Chrome extension whose functionality relies on options, so I’m calling the main function is called as a callback after fetching options from Chrome storage.

In testing on my machine, I’ve had faster results from using chrome.storage.sync.get, rather than chrome.storage.local.get, but it’s still slowing up the page load quite a bit. I wondered if that might be just my machine, and typically local.get would be faster, or if there’s a way to cache these settings to be more easily accessible.

Thanks for the help! 🙂

Chrome storage responds undefined

I have following function to make reading data from chrome storage easy:

function readExtensionStorage(key, callback) {
var myKey = key;
callback(chrome.storage.local.get(myKey, function (items) {
    if (!chrome.runtime.error) {
        if (JSON.stringify(items) == "{}")


I’m using the function like following:

readExtensionStorage(proxyName, function (value) {

But it responds two time and the first one always undefined. What am i doing false? I have a output like this:


How can I transfer data from a Google extension popup window to a database?

I need help with a Google extension. It records how long you are at a website and displays it in a popup. I would like to take that information and store it so that users can review their browsing habits. I read that connecting it to a database is too risky for a man-in-the-middle attack. What would be the best method to do this? I read that using IndexedDB would be a good alternative but I cannot find much information on how to specifically modify my code to connect to that. I am new at this, so I know that this question may be a bit simplistic.

Javascript promises not acting synchronously

I am attempting to use JavaScript promises so that the rest of my code waits for my asynchronous ‘chrome.storage.local.get’ call. However, it seems that the code is still acting asynchronously, and as a result sending undefined data out.

JavaScript code:

else if( request.message === "fetch-local-storage" ){//if popup request local data
        var responseData;

        let store = new Promise(function(resolve, reject){
            chrome.storage.local.get('localSearchList', function(query){
                responseData = query.localSearchList;
                console.log("asynch data: " + JSON.stringify(responseData));
            }); //fetch the local storage data 

        store.then(function(res){ //do this only after above code runs
            console.log("The data being sent to popup (via content.js pipeline): " + JSON.stringify(responseData));
            sendResponse({message: "local-storage-data", data: JSON.stringify(responseData)});


The console shows the following output:

The data being sent to popup (via content.js pipeline): undefined
asynch data: "[{"word":"mo","color":"rgb(128,0,128)","id":"0"}]"

If you look back at the code, this display shows that it is not working synchronously…

Variable being assigned within google chrome method not keeping its value

I am assigning the variable ‘responseData’ to the value of a variable in chrome local storage. When I console.log the value of response data right after assigning it, it prints out the value perfectly fine, however, if i do the exact same console.log statement a couple lines below it it says the value is undefined?

The JS code:

 else if( request.message === "fetch-local-storage" ){ //popup is reopening and fetching data cached in local storage
    console.log('Booting up popup....');
    var responseData;

    chrome.storage.local.get('localSearchList', function(query){
        responseData = query.localSearchList;
        console.log("responseData within conditional: " + JSON.stringify(responseData));
    }); //fetch the local storage data 

    console.log("Actual value being sent out:" + JSON.stringify(responseData));

    sendResponse({message: "local-storage-data", data: JSON.stringify(responseData)}); //send it as a JSON-ifiable object

Console.log output:

Booting up popup....
Actual output of content.js:undefined
responseData within conditional: "[{"word":"q","color":"rgb(0,128,0)","id":"0"}]"

Does this have to do with synchronality of the ‘get’ method, where sendResponse is executing before the get can finish so its left undefined?

will chrome extension update clear local storage?

I am developing chrome extension and want to keep some configs. I am using chrome.storage.sync API.

I am using this code for generating values once.

chrome.runtime.onInstalled.addListener(() => {
    chrome.storage.sync.get(['value'], data => {
        if (!data.userId) {
            chrome.storage.sync.set({ value: getRandomValue() }, () => {
                console.log('Settings saved');

I want to be sure, that my data will keep when user

1: Updates the extension

2: Removes the extension and installs it again.

Which of these cases will keep my values ?

Chrome Storage API – GET call

I am unable to understand Google chromes get and set functions.

Please refer the below code snippet.

    var v1 = 'l1';
    var v2 = 'l2';




I got the following output.
l1 s1
l2 s1

I am purposely not setting v2 as I would like to understand what the result is when the variable hasn’t been set yet.

I am not able to follow why get with key v2 returns s1.

Can you somebody pplease let me know where I am going wrong.


How do I use Promise.all() with chrome.storage()?

I have several async functions running. I want to wait for them all to finish before taking the next steps. Here’s my code that I’m using to get all of the key/values from chrome.storage and the Promise.all() implementation.

var promise1 = Promise.resolve(3);
var promise2 = 42;
var promise3 = new Promise(function(resolve, reject) {
  setTimeout(resolve, 100, 'foo');

var getAll = chrome.storage.sync.get(function(result) {

Promise.all([promise1, promise2, promise3, getAll]).then(function(values) {
  console.log(values); // [3, 42, "foo", undefined]

This doesn’t work unfortunately. It returns undefined.

Most of the code above is taken from MDN here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all