How to migrate user data from indexedDB to storage API

186 views
Skip to first unread message

NetDocuments

unread,
Apr 4, 2022, 1:25:59 PM4/4/22
to Chromium Extensions
Hello dear developers. I have a very serious problem with the my extension
I'm trying to migrate from manifest version2 to manifest version3
I have not been able to solve the following problem:
How to migrate user data from indexedDB to storage API (to work with service worker)?
At the moment I don't see any solution for this.
Could you please point me to the information on how to solve this.

Thank you!

PhistucK

unread,
Apr 4, 2022, 3:32:30 PM4/4/22
to NetDocuments, Chromium Extensions
Are you implying that indexedDB does not work in service workers? Because it should.

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/67c880b5-f877-4b88-9d33-6f076a1068f1n%40chromium.org.

NetDocuments

unread,
Apr 5, 2022, 9:36:19 AM4/5/22
to Chromium Extensions, PhistucK, Chromium Extensions, NetDocuments
Thanks for answering!
I'm currently (manifest v2) using an indexeddb in a background script.
And this database is not available after the migration (manifest v3) to the service worker. Isn't that how it should be?

indexeddb is available on the page itself where the content script "lives", but I can not access the indexeddb that was on the background script.
Maybe I'm doing something wrong.

wOxxOm

unread,
Apr 5, 2022, 10:04:40 AM4/5/22
to Chromium Extensions, ndde...@gmail.com, PhistucK, Chromium Extensions
IndexedDB is available in service workers, so I guess your code is using the ancient cross-browser method to access the API via `window`. Simply call indexedDB.open directly without any prefixes.

Robbi

unread,
Apr 5, 2022, 11:13:46 AM4/5/22
to Chromium Extensions, wOxxOm, ndde...@gmail.com, PhistucK, Chromium Extensions
May be that you cannot view the indexeddb in Devtools when you're inspecting the service workers?

NetDocuments

unread,
Apr 5, 2022, 12:04:27 PM4/5/22
to Chromium Extensions, wOxxOm, NetDocuments, PhistucK, Chromium Extensions
It looks like you were right.
Thank you very much for your help!

NetDocuments

unread,
Apr 13, 2022, 10:06:42 AM4/13/22
to Chromium Extensions, NetDocuments, wOxxOm, PhistucK, Chromium Extensions
I would like to clarify one more detail.
My indexed Database (which was in the background page at manifest v2 held data.
Is there a way to access this indexed database from the service worker (after migrating to the v3 manifest)?

After the migration, I don't see my indexed database.

wOxxOm

unread,
Apr 13, 2022, 10:25:29 AM4/13/22
to Chromium Extensions, ndde...@gmail.com, wOxxOm, PhistucK, Chromium Extensions
Your code in the service worker can access it directly: indexedDB.open()
To inspect IndexedDB visually in devtools, open any normal page of your extension like the popup, then use its devtools.

NetDocuments

unread,
Apr 13, 2022, 11:16:28 AM4/13/22
to Chromium Extensions, wOxxOm, NetDocuments, PhistucK, Chromium Extensions
Thank you, that is cool
Reply all
Reply to author
Forward
0 new messages