tshaddix / webext-redux

A set of utilities for building Redux applications in Web Extensions.
MIT License
1.22k stars 180 forks source link

Multiple Event Message Issues in "webext-redux": "3.0.0-mv3.0" #303

Open Lalg28 opened 3 weeks ago

Lalg28 commented 3 weeks ago

Hello,

I’m experiencing several errors with the "webext-redux": "3.0.0-mv3.0" version, primarily related to event messages. The errors are persistent and occur under specific conditions. Below is an example:

Screenshot 2024-08-26 at 6 26 48 p m

Based on my research, I suspect these issues might be caused by the absence of the return true; statement in the message handler, as shown in the following code snippet:

if (request.message === 'webext-example') { doAction(); return true; }

This statement is crucial to ensure proper message handling, especially when dealing with asynchronous actions.

Any help or guidance on resolving this would be greatly appreciated!

SidneyNemzer commented 1 week ago

Thanks for the report! I missed this in my testing because I didn't check what happens when non-webext redux messages are received by the service worker. It looks like this code is the cause:

https://github.com/tshaddix/webext-redux/blob/master/src/listener.js#L10-L11

To fix this, the function above needs to conditionally return true, only for messages that will be handled by webext-redux. I'll think through how to implement this.

In the meantime you can ignore the error -- it shouldn't cause any issues in your app.

Lalg28 commented 1 week ago

Thanks for your response, I'll take that in mind! 🤠