Skip to content
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

Fix browser errors about async responses #304

Merged
merged 4 commits into from
Oct 29, 2024
Merged

Conversation

SidneyNemzer
Copy link
Collaborator

Fixes #303

The issue was the deferred listener helper would return true (telling the browser to expect an async response) for every message, even if the messages were not from the library. In wrapStore(), those messages would be ignored causing the browser to log an error:

Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

This is mostly harmless, but it's better to avoid the error. In this commit, createDeferredListener() now takes a filter function that determines if the message will be handled so that messages from outside the library can be ignored.

Unfortunately this requires a breaking change: moving the channelName argument to createWrapStore(). This is required since the filter function needs to know which channel to expect before wrapStore() is called. I'm hoping that most consumers don't pass channelName so this won't affect most apps.

fixes #303

The issue was that the deferred listener
abstraction would `return true` (telling the
browser to expect an async response) for every
message, even if the messages were not from the
library. In `wrapStore()`, those messages would be
ignored causing the browser to log an error:

    Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

This is mostly harmless, but it's better to avoid
the error. In this commit,
`createDeferredListener()` now takes a `filter`
function that determines if the message will be
handled so that messages from outside the library
can be ignored.

This requires a breaking change: moving the
`channelName` argument to `createWrapStore()`.
This is required since the filter function needs
to know which channel to expect before
`wrapStore()` is called.
@SidneyNemzer SidneyNemzer merged commit dbfb07f into master Oct 29, 2024
3 checks passed
@SidneyNemzer SidneyNemzer deleted the async-response branch October 29, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Event Message Issues in "webext-redux": "3.0.0-mv3.0"
3 participants