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

The static build of Storybook 6 is DOA (sidebar links don't work) #11958

Closed
kaiyoma opened this issue Aug 12, 2020 · 32 comments
Closed

The static build of Storybook 6 is DOA (sidebar links don't work) #11958

kaiyoma opened this issue Aug 12, 2020 · 32 comments

Comments

@kaiyoma
Copy link

kaiyoma commented Aug 12, 2020

Describe the bug
Sidebar links in a static build of Storybook 6 don't work properly. Clicking on a link changes the URL, but the frame doesn't update and the rendering doesn't change. The first component loaded continues to appear on-screen.

I've tested 6.0.0, 6.0.4, and 6.0.5, and they all have this problem.

To Reproduce
Steps to reproduce the behavior:

  1. Run a static build (build-storybook)
  2. Serve index.html with a web server
  3. Click any link in the sidebar

Expected behavior
The UI should work correctly.

System:

My laptop:

Environment Info:

  System:
    OS: Windows 10 10.0.19041
    CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  Binaries:
    Node: 12.16.1 - C:\Program Files\Node.js\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.13.4 - C:\Program Files\Node.js\npm.CMD
  Browsers:
    Chrome: 84.0.4147.125
    Edge: Spartan (44.19041.423.0), Chromium (84.0.522.59)
  npmPackages:
    @storybook/addon-actions: 6.0.5 => 6.0.5
    @storybook/addon-knobs: 6.0.5 => 6.0.5
    @storybook/addons: 6.0.5 => 6.0.5
    @storybook/core: 6.0.5 => 6.0.5
    @storybook/react: 6.0.5 => 6.0.5
    @storybook/theming: 6.0.5 => 6.0.5

I'm seeing the same problems in our CI system, which runs Linux.

Additional context
Running the dev server (start-storybook) works correctly. It's only the static build that is broken. There are no warnings or errors during the build and no warnings or errors in the browser console. Storybook 5 did not have this issue.

@shilman
Copy link
Member

shilman commented Aug 13, 2020

Do you have a repro you can share?

@kaiyoma
Copy link
Author

kaiyoma commented Aug 13, 2020

Do you have a repro you can share?

Not easily. We run Storybook as part of a large, proprietary project, so I can't post any code. In the meantime, here's a clip showing the issue. Notice that the URL is changing, but the rendering is not.

storybook-links-broken

@shilman
Copy link
Member

shilman commented Aug 13, 2020

Are there any error messages in the browser console?

@dimpu
Copy link

dimpu commented Aug 13, 2020

Same issue for me too. Any update on this?
Version: 6.0.5

No console errors.

@shilman
Copy link
Member

shilman commented Aug 13, 2020

@dimpu do you have a repro i can look at?

@kaiyoma
Copy link
Author

kaiyoma commented Aug 13, 2020

I can try to work on a repro tonight or tomorrow. No messages in the browser console when this happens.

@shilman
Copy link
Member

shilman commented Aug 13, 2020

Really appreciate it @kaiyoma 🙏

If anybody's experiencing this problem and has a public repro, please share here or DM me on Discord

@kaiyoma
Copy link
Author

kaiyoma commented Aug 13, 2020

Here's a small, simple repro: issue-11958.zip

After you unzip:

  1. yarn install
  2. yarn run start-storybook
  3. Check the UI and see that clicking the sidebar links works fine
  4. yarn run build-storybook
  5. Load dist/storybook/index.html in the browser directly or load through a simple HTTP server
  6. Check the UI and see that clicking the sidebar links doesn't work

One other random observation, that may or may not be related: with either kind of build, after the UI loads for the first time, if you click a sidebar link for a different component, the first component's group closes up. Storybook 5 didn't work that way.

@shilman
Copy link
Member

shilman commented Aug 13, 2020

Thanks so much. Checking now!

@dimpu
Copy link

dimpu commented Aug 14, 2020

Hi @shilman Is there any update on this? I got this after I upgraded from 5 to 6 using npx sb upgrade.

@shilman
Copy link
Member

shilman commented Aug 14, 2020

Yes, was able to identify the problem with @tmeasday but still don't have any idea exactly why it's happening or how to fix.

The problem is on this line:
https://github.com/storybookjs/storybook/blob/master/lib/channel-postmessage/src/index.ts#L117

For reasons that we don't understand the iframe is getting re-rendered and the data-is-loaded attribute is getting cleared in the built storybook.

I've assigned this to @ndelangen who is most familiar with this part of the code for further investigation.

@dimpu
Copy link

dimpu commented Aug 14, 2020

Thanks @shilman .

@ndelangen
Copy link
Member

Back from vacation, This is on my agenda for this week!

@ndelangen
Copy link
Member

repro:

  • downloaded you zip
  • unzipped it
  • removed lockfile
  • upgraded storybook to latest version
  • ran start-storybook
  • storybook worked as expected for me
  • ran build-storybook
  • hosted the build storybook
  • storybook preview does indeed NOT update

broken:

  • click on a navigation
    expected: the item becomes selected
    actual: it's not selected
    notes: the URL does change

observations:

  • knobs work, so the channel isn't broken.
  • I'm seeing both attributes on the iframe:

Screenshot 2020-08-19 at 15 44 19

@ndelangen
Copy link
Member

It seems the storyId & path are never updated in the global state:
Screenshot 2020-08-19 at 15 49 35

@ndelangen
Copy link
Member

I'm still debugging this..

It seems something very strange is going on in the router:
I load the page, and click the "LabelValueTable > playground" 2x, and this is what I see in the logs:
Screenshot 2020-08-19 at 17 45 51

And yet...

  • The URL changes on the first click
  • The props of the Location component change on the second
  • the app state never changes

@ndelangen
Copy link
Member

disabling the DLL seems to resolve this issue (but result in a longer build-time)

for now, run build-storybook --no-dll if you run into this problem

@ndelangen
Copy link
Member

@kaiyoma I hope that work around works for you until we find the root cause

@kaiyoma
Copy link
Author

kaiyoma commented Aug 20, 2020

@kaiyoma I hope that work around works for you until we find the root cause

Yup, I can live with this. 😄 Thanks for digging into this!

@ndelangen
Copy link
Member

The digging must continue.

@kyleBeikirch
Copy link

disabling the DLL seems to resolve this issue (but result in a longer build-time)

for now, run build-storybook --no-dll if you run into this problem

Thanks @ndelangen, that worked for me!

@stale
Copy link

stale bot commented Sep 11, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Sep 11, 2020
@OfriHarlev
Copy link

OfriHarlev commented Sep 16, 2020

This is still an issue, is it still being actively worked on?

@shilman
Copy link
Member

shilman commented Sep 16, 2020

@OfriHarlev sort of. the workaround is to run with --no-dll. we're focusing on perf in 6.1 and part of that work is trying to get rid of the DLL, which should resolve a bunch of issues including this one.

@stale stale bot removed the inactive label Sep 16, 2020
@OfriHarlev
Copy link

When I add --no-dll I get this error
Error: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

From link above:
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

I checked that I only have one version of react yarn why react => [email protected] and that I have only one version of react dom and that its matching yarn why react-dom => [email protected]

I don't get this without --no-dll and I also don't get this error when using --no-dll with start-storybook

  Operating System: Mac OS 10.14.6
  npm packages:
  "@storybook/addon-a11y": "6.0.21",
    "@storybook/addon-essentials": "6.0.21",
    "@storybook/addons": "6.0.21",
    "@storybook/react": "6.0.21",

@stabback
Copy link
Contributor

@shilman Thanks for your work here. I just burnt an hour debugging this before coming across this issue. Since this is a known problem, I'm happy to update the documentation with a link to this issue and a brief explanation.

The docs could use some information here on these two pages:

Do you agree the documentation should be updated until 6.1 introduces a proper fix?

@shilman
Copy link
Member

shilman commented Oct 15, 2020

@stabback Thanks for the offer! I believe the documentation for --no-dll was updated recently by @jonniebigodes in the FAQ, but I'm certainly open to adding it in other places if it's helpful

@jonniebigodes
Copy link
Contributor

@stabback we welcome changes to the documentation. I'm ok with some changes to both pages you mentioned.
Regarding the changes you're proposing, we could do the following:

  • cli-options we could adjust the wording a bit and give a clearer message.
  • publish-storybook short term until 6.1 lands we could tweak the wording a bit to address the issue at hand give a clearer message.

Loop me in when you've created the pull request if you don't mind and we'll take it from there.

Sounds good

@stabback
Copy link
Contributor

@jonniebigodes @shilman

#12814

Not super happy with the duplication of the docs, but as it'll be removed with the fix in 6.1 it's only temporary.

Hopefully, it helps save someone a couple of hours of debugging!

@shilman
Copy link
Member

shilman commented Oct 22, 2020

Workaround & documented. Closing. Will remove DLL in 6.1 #12637

@elliothershberg
Copy link

I've run into this issue with sidebar links from the output of build-storybook. Unfortunately, adding the --no-dll doesn't resolve this for me. I'm using Storybook 6.0.28, so I will upgrade to see if that works, but if the only change is regarding DLL, I'm not sure it will make a difference.

@elliothershberg
Copy link

Upgrading to Storybook 6.1.20 actually did resolve it for me 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants