question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with multiple stores (redux-saga)

See original GitHub issue

Hi, I use multiple stores on a serverside Redux projects. I also use the redux-saga middleware.

When I enable remote-redux-devtools, I get a mixup of states. It seems the middleware is merging all actions dispatched on any store into the last store. I only see the latest store in remotedev.io and the redux generator function (main) of the last store seems to “take” all the actions.

I initialize with different names for the “instances”, all in the same process.

Could there be an issue with multiple remote-redux-devtools in the same process, or something with sagas?

I tried deleting the node “require-cache” between calls, to no avail.

My source (typescript) below, work in progress. I have commented out the devtools and things work perfectly.

const RemoteDevTools = require('remote-redux-devtools')
const {composeWithDevTools} = RemoteDevTools

function* mainLoop() : any {
	const {scenarioId} = yield take(SET_SCENARIO)
	console.log("got scenario: ", scenarioId)
	const channel = yield actionChannel('*')
	yield delay(2000)
	yield put(initialized())
	const testState = (yield select()) as IState
	console.log(`state scenario: ${testState.initialized.scenarioId}`)
	while (true) {
		const action = yield take(channel)
		console.log(`got action (${scenarioId}): `, action)
	}
}

export function createScenarioStore(scenarioId: string) {

	// This causes the remote dev tool to use remotedev.io, which can be accessed at remotedev.io/local
	const composeEnhancers = composeWithDevTools({ realtime: true, name: `scenario_${scenarioId}` }) 
	
	const middleware = createSagaMiddleware()
	const store = createStore(mainReducer, applyMiddleware(middleware)) // composeEnhancers(applyMiddleware(middleware)))

	middleware.run(mainLoop)
	store.dispatch(setScenario(scenarioId))

	return store
}

BTW: This project / tool is absolutely excellent!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jtag05commented, Mar 24, 2017

Hi just to give an update. I have a feeling I have a very unique problem in that I’m currently running both stores from the same remote-redux-devtools node module. It then occurred to me that the module is a singeton and that would explain why using composeWithDevtools was causing conflicts between my two stores.

0reactions
slaivyncommented, Sep 10, 2019

I found out that this issue is fixed in master thank to @Lukermelesh (PR #132) and is only published to the beta channel. So for anyone interested: install remote-redux-devtools@beta (and use remote-redux-devtools) Thank you @zalmoxisus for this fantastic tool! Thank you @Lukermelesh for this fix absolutely necessary for my use case!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple redux-sagas - Stack Overflow
Redux Saga uses the all function in the recent version (0.15.3) to combine multiple sagas to one root saga for the Redux store....
Read more >
API Reference - Redux-Saga
Creates a Redux middleware and connects the Sagas to the Redux Store. options: Object - A list of options to pass to the...
Read more >
Introduction to Redux Saga | LoginRadius Blog
Redux Saga is a middleware library used to allow a Redux store to interact with resources outside of itself asynchronously. This includes making...
Read more >
Redux vs. MobX: Which performs better? - LogRocket Blog
MobX can have multiple stores that store the state of an application · Anything derived from the state without any further interaction is...
Read more >
Handling Middleware With Redux-Saga - Telerik
The way to effectively resolve this issue is to use a state management medium—Redux comes in here. As defined earlier, Redux is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found