Skip to content

The state is patched twice if the extension is opened in a separate tab #311

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

Open
EgorKazachenko opened this issue Apr 11, 2025 · 1 comment

Comments

@EgorKazachenko
Copy link

const serializedMessagePoster = withSerializer(serializer)((...args) => {

Hi, thanks for amazing library. I get the wrong behavior when i open my extension as a separate browser tab. Due to this code

browserAPI.runtime.sendMessage(...args, onErrorCallback);
  // We will broadcast state changes to all tabs to sync state across content scripts
  return browserAPI.tabs.query({}, (tabs) => {
    for (const tab of tabs) {
      browserAPI.tabs.sendMessage(tab.id, ...args, onErrorCallback);
    }
  });

My UI's store getting same patch twice and as i use custom diff/patch strategy (works like a regular redux without IPC de/serialization issues) for my useEffect's etc. it's a bit unexcpected for example when some item is added to some list inside the state and replaced by the item with the same structure but with a different refference right after. "remove" patch works even more fun :)

Could you please clarify if this is intended or is it a bug?

Thanks!

@SidneyNemzer
Copy link
Collaborator

Hey there, thanks for creating an issue. I don't have time to look into this right now but hopefully I'll be able to dedicate some time to this library soon.

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

No branches or pull requests

2 participants