ghostery-extension: Error in console: Uncaught (in promise)

On any site, an error appears in the console:

Uncaught (in promise) {message: 'A listener indicated an asynchronous response by r…age channel closed before a response was received'} message: "A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received"

It interferes quite a lot when working in the console

Steps to Reproduce

To check, you can go to https://www.google.com/, open the console and click on an empty space. Several errors will appear almost immediately.

Versions

  • Browser: Chrome 102.0.5005.115

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 19 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Hello I confirm the bug on

  • Chrome: v106.0.5249.119 (Official Build) (arm64)
  • Ghostery: v8.7.4

It looks like after the update the error stopped repeating. Thanks

To explain the reasoning behind merging https://github.com/ghostery/ghostery-extension/pull/830:

For parts like the adblocker, Ghostery needs to communicate between the background (the extension) and the content script (the website). Firefox and Chrome have similar APIs, but with a different interface - Firefox is promise-based, while Chrome uses callbacks (in Manifest V2). For that reason, we are using the webextension-polyfill library, which enables us to have a Firefox-like API on Chrome.

As part of their implementation, the polyfill library detected a specific error message from Chrome without showing a warning. In the context of Ghostery that can be seen as a implementation detail, as long as the communication between content script and background works as in Firefox. Now Chrome recently changed its code and the original error message was changed and split into two different message. That is why suppressing the warning inside the library no longer works.

The fix that is being discussed in https://github.com/mozilla/webextension-polyfill/issues/384 is to update the detection code to cover the new text of the error messages. It is not merged (waiting for test coverage), but it solves the problem already in Ghostery and I could not find negative side-effects while testing it. If it gets officially merged and released, we can upgrade the library and drop the npm-patch, of course.