7

I have a simple extensions that saves some data to chrome storage

var dt = new Date();
var item = {};
item[$('#qteSymb').text() + "-" + guid()] = $('#newnote').val() + "-:-" + $.datepicker.formatDate('mm/dd/yy', dt) + " " + dt.getHours() + ":" + (dt.getMinutes() < 10 ? "0" + dt.getMinutes() : dt.getMinutes());           
chrome.storage.sync.set(item, function(){
    renderNotes();
});   

This works fine locally - my extension is working as intended - but it doesn't sync back to another computer. I am assuming the sync is ON on both computers because the bookmarks, extensions, etc. sync just fine.

Thank you!

americanslon
  • 4,048
  • 4
  • 32
  • 57

1 Answers1

16

So I finally figured this out. When not using Chrome Web Store your manifest file should include a key (https://developer.chrome.com/extensions/manifest.html#key)

...
"key":"myawesomeextension"
...

Without this every time you install the extension on a different device (through chrome://extensions/ --> Load unpacked extension) it gets a new id and therefore the data being synced doesn't get matched to the correct extension - same extension with different ids = two different extensions in the eyes of Chrome.

There is no need for a key once the extension is in Chrome Web Store. Hope this helps somebody keep some hair at some point.

americanslon
  • 4,048
  • 4
  • 32
  • 57
  • Failed to load extension from: ~\Documents\.. Value 'key' is missing or invalid. – GorvGoyl Sep 05 '16 at 18:56
  • Do you know if this is still an issue today ? – Magix Nov 16 '16 at 17:44
  • 2
    This is still and issue today and using a `key` solved my issue. You cannot put any string in there though. It has to be a valid Chrome extension string. You can find these strings from your extension if you load it up and call `chrome.runtime.getURL('')`. – Kevin Ghadyani Oct 01 '19 at 03:40
  • Adding the key did NOT solve my issue... the data is still not being synced... – ykonda Oct 05 '21 at 03:12
  • @ykonda you have to make sure you update your extension in both machines. – BobTheSatan Dec 10 '21 at 14:18