-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received #384
Comments
This might actually be an opportunity to fix this very related issue: But I'd still rather see a quick fix merged as soon as possible at least to preserve the old behavior. |
This changed in https://bugs.chromium.org/p/chromium/issues/detail?id=1304272. The fix in #385 looks good. |
This error message indicates that there was a problem with the communication between the listener and the message channel. The reason is that sendMessage is now promisified internally, so you can 'await' it, but the by-product is that when you don't specify a callback yourselves, it is added internally anyway in order for the call to return a Promise, which means that since you don't call sendResponse in onMessage, the API will think that it was you who made a mistake of using a callback and not providing a response, and report it as such. Since the new behaviour is very confusing for almost everyone, a solution might be to stop showing this error when the callback is not specified, however it might cause confusion for those developers who still use callbacks and forgot to call sendResponse inside onMessage by mistake, which should be reported ideally as it always was. If you see your extension causing this errors - inspect closely all your onMessage listeners. Some of them probably need to start returning promises (marking them as async should be enough). If still error showing, try disabled all installed extensions in Chrome then you will get a clear console without errors. |
This is not a Chrome issue. This is an Adobe PDF extension issue. If you disable the Adobe PDF extension it will go away proving this fact. Johnny. |
I've been struggling with this since I setup OneSignal on my site and YES, I have the PDF extension active on my Chrome and YES, after I deactivated the extension, the error has not appeared since. Never would have thought to look for the fix concerning Adobe PDF, thank you! |
You are very welcome. I try to post all I find that I have noticed. Have a great day. |
In my case it seems that the "Shoop Cashback & Gutscheine"-Chrome-Extension causes this message, as it came after installing that said extension und it doesn't come after deactivating that extension... |
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
Then close the tab
Polyfill repro
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:
webextension-polyfill/src/browser-polyfill.js
Line 14 in 780518e
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 theonMessage
listenerPossible 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 😁
Related
tabs.sendMessage()
#365The text was updated successfully, but these errors were encountered: