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

npx sb extract not working as expected #13561

Closed
Niznikr opened this issue Jan 5, 2021 · 26 comments
Closed

npx sb extract not working as expected #13561

Niznikr opened this issue Jan 5, 2021 · 26 comments

Comments

@Niznikr
Copy link

Niznikr commented Jan 5, 2021

Describe the bug
Running npx sb extract results in the following error:

npx sb extract
info connecting to: http://localhost:57011/iframe.html
info installing puppeteer...
TimeoutError: waiting for function failed: timeout 30000ms exceeded
    at new WaitTask (/Users/rniznik/.npm/_npx/37097/lib/node_modules/sb/node_modules/puppeteer-core/lib/DOMWorld.js:549:28)
    at DOMWorld.waitForFunction (/Users/rniznik/.npm/_npx/37097/lib/node_modules/sb/node_modules/puppeteer-core/lib/DOMWorld.js:454:12)
    at Frame.waitForFunction (/Users/rniznik/.npm/_npx/37097/lib/node_modules/sb/node_modules/puppeteer-core/lib/FrameManager.js:657:28)
    at Page.waitForFunction (/Users/rniznik/.npm/_npx/37097/lib/node_modules/sb/node_modules/puppeteer-core/lib/Page.js:1141:29)
    at read (/Users/rniznik/.npm/_npx/37097/lib/node_modules/sb/node_modules/@storybook/cli/dist/extract.js:30:14)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async extract (/Users/rniznik/.npm/_npx/37097/lib/node_modules/sb/node_modules/@storybook/cli/dist/extract.js:87:18)

To Reproduce
Steps to reproduce the behavior:

  1. Go to a Storybook project
  2. Run npx sb extract from the terminal

Expected behavior
The command runs and creates a stories.json file.

Environment Info:

  System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  Binaries:
    Node: 14.15.1 - ~/.nvm/versions/node/v14.15.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.1/bin/npm
  Browsers:
    Chrome: 87.0.4280.88
    Edge: 87.0.664.66
    Firefox: 84.0.1
    Safari: 14.0.2
  npmPackages:
    @storybook/addon-a11y: ^6.1.11 => 6.1.11 
    @storybook/addon-actions: ^6.1.11 => 6.1.11 
    @storybook/addon-controls: ^6.1.11 => 6.1.11 
    @storybook/addon-docs: ^6.1.11 => 6.1.11 
    @storybook/addon-storysource: ^6.1.11 => 6.1.11 
    @storybook/addon-viewport: ^6.1.11 => 6.1.11 
    @storybook/addons: ^6.1.11 => 6.1.11 
    @storybook/react: ^6.1.11 => 6.1.11 
    @storybook/source-loader: ^6.1.11 => 6.1.11 
    @storybook/theming: ^6.1.11 => 6.1.11 
    @storybook/web-components: ^6.1.11 => 6.1.11 

Additional context
Add any other context about the problem here.

@diegofss11
Copy link

Did it work yet?

@Niznikr
Copy link
Author

Niznikr commented Feb 18, 2021

Nope still failing.

@shilman
Copy link
Member

shilman commented Feb 18, 2021

Perhaps you can install puppeteer manually by hand to avoid hitting this timeout? It's slow to install. @ndelangen WDYT?

@Niznikr
Copy link
Author

Niznikr commented Feb 18, 2021

Still times out even after manual install.

@cy6erskunk
Copy link

The same issue here... It seems that there's no way to use pre-intalled puppeteer if understood #13724 correctly.

@NiklasPor
Copy link

Ran into the same issue. Strangely I resolved it by calling sb extract from the root of the repository with the dist folder as a parameter:

npx sb extract dist/storybook/your-lib/

This strangely worked in opposite to cd dist/storybook/your-lib/ && sb extract in my case.

@pjoulot
Copy link

pjoulot commented Jul 22, 2021

Same issue here.
Installing the package manually seems to not work for me.

@mtsmachado8
Copy link

Same issue here... It's a really bad bug because i cannot use storybook composeable feature.

@shilman
Copy link
Member

shilman commented Aug 10, 2021

There is an experimental built-in stories.json generation. Here's how to use it:

  • Upgrade 6.4-alpha (npx sb upgrade --prerelease)
  • Only works on CSF & MDX stories (no storiesOf)
  • Set the following experimental flag in your .storybook/main.js config:
module.exports = {
  features: {
    buildStoriesJson: true,
  }
};

Then when you yarn build-storybook it should also generate stories.json in the output folder. This stories.json is not exactly the same format as what comes out of sb extract, but it seems to work pretty well already even though it's experimental. It will become the default in 6.4.

@ndelangen
Copy link
Member

Taking a look at this today

@ndelangen ndelangen self-assigned this Oct 28, 2021
@ndelangen
Copy link
Member

@tmeasday I'm hitting this line:

throw new Error('Cannot call extract() unless you call cacheAllCSFFiles() first.');

can you fill me in on the background info in this?

@tmeasday
Copy link
Member

tmeasday commented Oct 28, 2021

@ndelangen in order to call extract() you need to initialize and pre-cache the store.

In v6 mode that happens automatically and syncronously, so it shouldn't be an issue.

In v7 mode, you need to await preview.cacheAllCSFFiles() before calling functions like store.getStoriesJson(). So we would need to do that in the extract script.

There isn't really any reason to call extract in v7 mode, seeing as a build will generate (the same) stories.json anyway. But I guess we should fix it nonetheless.

@shilman
Copy link
Member

shilman commented Nov 4, 2021

ZOMG!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-beta.27 containing PR #16505 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Nov 4, 2021
@itwasmattgregg
Copy link

I'm on v6.4.13 and am getting this error. I'm not opted in to v7 store mode.

@itwasmattgregg
Copy link

Coming back to this: I figured out I was starting to use auto generated titles. For some reason removing the explicit titles on stories caused this error to fire on our custom a11y test function which currently uses extract.

@tmeasday
Copy link
Member

tmeasday commented Jan 31, 2022

@itwasmattgregg I will be looking at a fix to this soon.

@stabback
Copy link
Contributor

stabback commented Feb 8, 2022

Regarding this: #13561 (comment)

I ran into this error on 6.4.18 on the v6 store @tmeasday. We are using a mix of modern CSF and legacy storiesOf in our codebase. I'm wondering if the storiesOf syntax is confusing things.

I had to downgrade back to 6.3.x to avoid this issue.

@tmeasday
Copy link
Member

tmeasday commented Feb 8, 2022

@stabback -- you are hitting the line "Cannot call extract() unless you call cacheAllCSFFiles() first." on the v6 store? That's surprising -- do you have a reproduction you can share?

@stabback
Copy link
Contributor

stabback commented Feb 8, 2022

Unfortunately, I do not have a reproduction I can share :(. I was commenting hoping the additional context of the mix of CSF and storiesOf could help explain some of the discrepancies. I can reliably cause this error by updating from 6.3 to 6.4, with no other change to my code.

@tmeasday
Copy link
Member

tmeasday commented Feb 8, 2022

@stabback can you share your main.js and preview.js?

@stabback
Copy link
Contributor

stabback commented Feb 9, 2022

@tmeasday Happy to continue this off the public GitHub issue, however let's be sure to post the findings back here once resolved.

@shilman
Copy link
Member

shilman commented Feb 11, 2022

Ermahgerd!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.39 containing PR #17447 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

@shilman
Copy link
Member

shilman commented Feb 12, 2022

Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.19 containing PR #17447 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

@ritz078
Copy link
Contributor

ritz078 commented Jul 22, 2023

I am on 7.1.0 and I am still facing this issue.

@HashemKhalifa
Copy link

I'm on 7.4.1 and still facing the same issue!!

@HashemKhalifa
Copy link

the way to solve this issue is to override puppeteer-core in the package.json with version 13.7.0

I'm using pnpm so it will be


  "pnpm": {
    "overrides": {
      "puppeteer-core": "^13.7.0",
    }
  },

you can use resolutions in case of yarn, npm

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