I'm studying chrome extension MV3 recently. I've try to run chrome.runtime.sendMessage() example code. https://developer.chrome.com/docs/extensions/reference/runtime/
The example was writing chrome.runtime.sendMessage() to "contents.js" and chrome.runtime.onMessage.addListener() to background.js .
/// popup.js
chrome.runtime.sendMessage('get-user-data', (response) => {
console.log('received user data', response);
});
// background.js
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message === 'get-user-data') {
console.log(message);
}
});
But I written sendMessage to popup.js . I show my extension popup pane then chrome has crashed.
So I've try to watch chrome debug log.
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-logging --v=1
It had appear one warning .
[0504/063939.130152:WARNING:process_memory_mac.cc(93)] mach_vm_read(0x7ffee5ab0000, 0x2000): (os/kern) invalid address (1)
"invalid address" ? This is chrome bug ? or I can't write runtime.sendMessage() on popup.js ?