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

store.ready never resolved when there are other listeners (firefox) #308

Open
Choucroute-melba opened this issue Nov 20, 2024 · 2 comments

Comments

@Choucroute-melba
Copy link

Hello,

First of all thanks for your work, this package really come in a handy when struggling to manage an extension's state.

For a project I need to exchange some informations using runtime.onMessage alongside the store, and it seems that when the background page add another listener to runtime.onMessage, the proxy store doesn't initialize himself properly and the ready promise is never resolved, wich is blocking the entire application.

I tested in chrome and firefox with the following extension, and only firefox have this problem, maybe related to different manifest V3 support ?
https://github.com/Choucroute-melba/webext-redux-example

There is no specific error message.
tested on firefox dev edition 133.0b9, windows.

// background.ts

import {createWrapStore} from 'webext-redux';
import {configureStore} from "@reduxjs/toolkit";
import counterReducer from "./counterSlice";
import browser from "webextension-polyfill"

const store = configureStore({
    reducer: {
        counter: counterReducer,
    },
    middleware: getDefaultMiddleware => getDefaultMiddleware({
    }).concat(() => {
        return next => action => {
            console.log((action as any).type, "", (action as any).payload)
            return next(action)
        }
    })
}); // a normal Redux store

const wrapStore = createWrapStore()
wrapStore(store);
console.log("store created");

// remove this and the proxy store will work perfectly
browser.runtime.onMessage.addListener(async function(msg, sender) {
    const message = msg as any
    console.log("message", message)
});

Hope this can be fixed soon.
Thanks in advance,

Vivien

@SidneyNemzer
Copy link
Collaborator

Thanks for the report, that's very helpful! Unfortunately I don't have much time for this project right now but I'll try to investigate within the next few weeks. I didn't test on Firefox, I was hoping it would work the same as Chrome but looks like that's not the case 😞

@EgorKazachenko
Copy link

I have an extension built for chrome using manifestV2. I don't know the real reason but the same behaviour described by @Choucroute-melba happens often for some users of the product and this does not depend on the operating system or machine characteristics. Sorry for the lack of details, I'm trying to figure out the problem at the moment. The only thing i can notice is that there is Unchecked chrome.runtime.lastError in the console. I hope the comment will be useful, maybe someone with the same problem will come to the comments 🙂

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

3 participants