-
Notifications
You must be signed in to change notification settings - Fork 233
Description
I'm seeing this message in Chrome 102 and the 5-result search page suggests that this is a new message: https://www.google.com/search?q=%22A+listener+indicated+an+asynchronous+response+by+returning+true%22
No-polyfill repro
// in background
chrome.tabs.sendMessage(65, 'good soup', () => console.error(chrome.runtime.lastError))
// in tab
chrome.runtime.onMessage.addListener(() => true)Then close the tab
Polyfill repro
// in background
await browser.tabs.sendMessage(65, 'good soup')
// in tab, never-resolving promise
browser.runtime.onMessage.addListener(() => new Promise(console.info))Then close the tab
What's happening
My guess is that Chrome used to return "The message port closed before a response was received." but now it returns a different message, which isn't handled here:
| const CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE = "The message port closed before a response was received."; |
To be clear, Chrome still immediately returns the previous message when chrome.runtime.onMessage.addListener was never called. Here's what the call looks like before and after installing the onMessage listener
Possible solution
Feel free to update the PR or replace it with your own solution, I just hope this is fixed in a timely manner because you'll likely get more issues like this one 😁

