I'm developing a Chrome extension which scrappes some data via content scripts and passes one composite object to the background worker.
In the passed object, I have many properties. Some are strings, some are integers, some arrays and 3 of them are Map
objects.
The thing is: these Map
objects are stripped in the proccess. I console.log
the same object immediatelly before sending and after receiving, and the 3 properties which are Map
objects become empty objects:
In content script:
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
if (msg.attemptedStartScrapping) {
try {
fetchInfo()
.then(info => {
console.log({content: info})
sendResponse(info)
})
return true
} catch (e) {
if(!(e instanceof NotHomepageException)) console.error(e)
}
}
})
In bg worker:
chrome.action.onClicked.addListener(tab => {
const details = { tabId: tab.id }
sendMessage(details)
})
function sendMessage(details) {
chrome.tabs.sendMessage(
details.tabId,
{
attemptedStartScrapping: true,
tabId: details.tabId ?? null,
},
info => {
console.log({ worker: info })
}
)
}
Console outputs:
Any thoughts? Did we find a bug in message passing?