[Bug]: Storybook and `next-dynamic` not resolving suspense
#29255 opened on Oct 1, 2024
Description
Describe the bug
Creating this issue on behalf of GoodRx. They provided a repro here, including the steps to reproduce below from their readme for quick reference.
Reproduction link
https://github.com/dmytrobondarchukGoodRx/storybook-dynamic
Reproduction steps
Steps to reproduce
- Clone the repo
- Run
yarn - Run
yarn storybookoryarn build-storybook && npx http-server ./storybook-static - Open the provided storybook url and open NextJs dynamic issue story folder
There are four stories here:
One is using the default CheckUserSession component (Not dynamic story) and others use the next-dynamic wrapper of that component called CheckUserSessionDynamic:
- Dynamic - parent and child components use
fetchto get data - Dynamic Child Non Async - child components don't make async calls (mock data)
- Dynamic All Aon Async - child and parent components don't make async calls (mock data)
During each story open the Network tab in browser tools
You will get two behaviors:
Not dynamic behavior
The page will show one main spinner from the Story's suspense and then shortly a lot of spinners for each post after resolving /posts route and will execute each HTTP request once and will show the content in a few seconds
Dynamic behavior
The page will show only the main spinner from Story's suspense and will keep spaming HTTP calls to /posts route from the <Posts /> component (except Dynamic All Aon Async story)
The same behavior was confirmed on prod environment with infinite calls to HTTP endpoint (which was added to check if re-render (?) was happening)
System
"@chromatic-com/storybook": "^1.6.1",
"@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-interactions": "^8.2.9",
"@storybook/addon-links": "^8.2.9",
"@storybook/addon-onboarding": "^8.2.9",
"@storybook/addon-styling-webpack": "^1.0.0",
"@storybook/blocks": "^8.2.9",
"@storybook/nextjs": "^8.2.9",
"@storybook/react": "^8.2.9",
"@storybook/test": "^8.2.9",
"storybook": "^8.2.9",
Additional context
No response