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

Initialization Actions are Handled Multiple Times by Original Reducer When Using Lazy/Suspense #15

Open
pahund opened this issue Jan 24, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@pahund
Copy link
Member

pahund commented Jan 24, 2019

In the Next Gen MOTOR-TALK app, an action INIT_REFRESHABLE_AD_PLACEMENT is dispatched when the RefreshableAd component has been mounted.

The original reducer of the app handles this action to set a timestamp that allows us to refresh the ad slot when the pagination is used (see Jira ticket PLY-711).

When we use withBrick or withBricks from modular-toolkit/bricks to dynamically install bricks to the application, the original reducer is replaced with a new one that includes the reducers of the bricks.

Next Gen MOTOR-TALK uses this to lazy-load the three sidebar elements “Board Info”, “Board Facilitators” and “FAQ”.

The enhanced reducer handles the INIT_REFRESHABLE_AD_PLACEMENT action four times, presumably once for the original reducer and once for each of the three installed bricks.

This causes the ad creatives for the sidebar rectangle, left skyscraper and right skyscraper to be requested from the DFP ad server four times each.

Subsequent actions, e.g. REFRESH_AD_PLACEMENT are handled by the reducer correctly, i.e. only once.

@pahund pahund added the bug Something isn't working label Jan 24, 2019
@pahund pahund self-assigned this Jan 24, 2019
@pahund
Copy link
Member Author

pahund commented Jan 25, 2019

I've updated the unit tests and created an integration test, they all fail to reproduce the issue. I found out that the problem occurs only when Bricks are lazy-loaded using React.lazy and Suspense.

If I load the sidebar elements in Next Gen MOTOR-TALK without lazy/suspense, the INIT_REFRESHABLE_AD_PLACEMENT is handled only once by the reducer, as it should.

@pahund
Copy link
Member Author

pahund commented Jan 25, 2019

👷🏻‍♀️ TODO – write another integration test that uses lazy/suspense that reproduces the issue

pahund pushed a commit that referenced this issue Jan 25, 2019
…actions only once

Change-Id: I9d4dc8d803372249df46b21b7feb57a89d783acf
pahund pushed a commit that referenced this issue Jan 25, 2019
…eset the mocks – d'oh!

Change-Id: If89f8c79a05eb28020b6e7ed75ad5516a9a00a14
pahund pushed a commit that referenced this issue Jan 25, 2019
Change-Id: Ia96ded6f96505f05ae6fd5076954262715eb2f68
@pahund pahund changed the title Initialization Actions are Handled Multiple Times by Original Reducer Initialization Actions are Handled Multiple Times by Original Reducer When Using Lazy/Suspense Jan 25, 2019
@pahund pahund removed their assignment Mar 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant