wOxxOm
unread,Mar 29, 2024, 2:18:21 PM3/29/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, Kabir Singh, Patrick Kettner, Chromium Extensions, wOxxOm
Messaging in Chrome is still using the ancient JSON-compatible protocol (number, boolean, string, null, and array/object of such types, own keys only, no self-references). Firefox supports StructuredClone algorithm required to transfer Map/Set, maybe Safari as well.
In Chrome you'll have to serialize everything that's not a JSON type e.g. convert map to [...map] and then recreate it after receiving the message using new Map constructor. There may be an existing library for serialization, but it's not hard to write one yourself.
Unfortunately, ManifestV3 has wasted a lot of effort on pursuing impractical ideas such as switching to a service worker (it turned out to be a lot more complicated due to bugs and the very fact that a service worker is architecturally anatagonistic to a locally hosted extension), so I wouldn't expect this to be implemented anytime soon. There was an abandoned attempt to switch to the structured clone algorithm several years ago, but that developer has left the team.