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.

asyncPropsExtenders are applied multiple times. This causes a growing amount of requests.

See original GitHub issue

Describe the bug Website fails to render properly. Plone backend logs a growing list of requests of actions registered with asyncPropsExtenders in add-on volto-dropdownmenu

To Reproduce

  • set up Volto with add-on volto-dropdownmenu
  • log Volto asyncConnect replacement
const applyExtenders = (asyncItems, pathname) => {
  console.log('applyExtenders', asyncItems);

Software (please complete the following information):

  • Volto 12.4.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
giuliaghisinicommented, Apr 9, 2021

yes is in volto-dropdownmenu. We tried to remove it, because it also works without async loading, and we found that there’s the problem for all the asyncConnect calls. We have seen a lot of request on plone for all asyncConnect in App.jsx. So, the problem i think is not only with asyncPropsExtenders, but with all asyncConnect, or maybe ssr is done multiple time for one page…

0reactions
tiberiuichimcommented, Apr 9, 2021

For the “record”, here’s @giuliaghisini + @nzambello’s solution:

  config.settings.asyncPropsExtenders = [
    ...(config.settings.asyncPropsExtenders ?? []),
    {
      path: '/',
      extend: (dispatchActions) => {
        if (
          dispatchActions.filter(
            (asyncAction) => asyncAction.key === 'dropdownMenuNavItems',
          ).length === 0
        ) {
          dispatchActions.push({
            key: 'dropdownMenuNavItems',
            promise: ({ location, store: { dispatch } }) =>
              __SERVER__ && dispatch(getDropdownMenuNavitems()),
          });
        }
        return dispatchActions;
      },
    },
  ];

From the solution, it looks like this: the extend() function can be called multiple times (I’ll have to see if that’s normal or not), so you have to protect against pushing multiple times your dispatch.

Sorry about this… it’s been a while since I’ve been looking at that code, so I’ll have to familiarize myself again with it. In any case, there’s still the odd behavior of the double SSR call. Worth investigating.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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