Skip to content

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

Open
@Choucroute-melba

Description

@Choucroute-melba

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

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