Skip to content

state reset when opening a second context #313

@yegor211

Description

@yegor211

Hello there guys,

This issue is driving me crazy and messes up the extension flow by a margin. It was acting slightly different before, but I’ll start with the current behavior (shows up in @4.0.0) and then describe how it used to behave — feels like the same root issue, just slightly different outcome.

So, we’ve got two contexts using proxyStore (new Store()): side panel and options page (background acts as SSOT). But this isn’t tied to just those — anything creating a proxyStore triggers it. For example: open options page → duplicate tab → the original options page gets wiped. Same thing happens if you open any other extension page (like /test.html) — same result.

To rule out any weirdness from our code, I trimmed both the side panel and options page down to just rendering a <Test /> component that displays part of the state (user data). Nothing else is running in either context during repro.

Repro steps:

  • Open options page
  • Then open side panel
    → options page gets reset (state goes back to initial)

Same thing if you flip it:

  • Open side panel
  • Then open options
    → side panel state gets wiped

I’ve tried pretty much everything I can think of. Latest attempt is patching the package and dropping in some logs to see what’s going on.

Here’s a screenshot of the options page logs after opening the side panel:

Image

You can see the user data is empty, and there’s a state replacement action happening. No idea why it logs twice (might be a separate thing), but both messages carry the initial state within the payload. I don’t think these messages even fire when just opening the options page — they only pop up when you open the side panel (or whatever with the proxyStore) afterward.

I thought maybe it’s related to outdated react / react-redux / react-dom versions (... just in case?) — updated everything to the latest (fixed what broke along the way) — had zero effect.

If this isn’t enough context, I can explain the setup/etc further. I wasn’t the original dev, and the setup is pretty gnarly (way too much going on under the hood). Webpack is the bundler.

REALLY looking forward for the help - this is affecting a lot of customers and raises questions...

PS: For the previous behavior when we were running something around @2.x.x version - it was kinda the opposite. Open options page -> open side panel -> side panel gets wiped almost instantly. And vice versa.
PSS: I was trying with/without persist. If I persist ALL the keys, the bug will still take place, but the state will get picked up after a quick blink of an empty (initial) state (it is quite visible in our case because it's a login view). Without persist at all, it always breaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions