storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.56k stars 9.3k forks source link

[Bug]: EBUSY: Resource busy or locked #23131

Open luked177 opened 1 year ago

luked177 commented 1 year ago

Describe the bug

We recently upgraded to Storybook v7 and now some of our team are struggling to run the updated version of Storybook. We previously had this same issue in v6, however the fix stated in this thread Issue19336 worked for us until now with the upgrade to v7 :(

To Reproduce

Run npm run storybook after upgrading to v7

System

Environment Info:

  System:
    OS: Windows 10 10.0.22621
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
  Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1848.0), Chromium (114.0.1823.51)
  npmPackages:
    @storybook/addon-a11y: ^7.0.21 => 7.0.21
    @storybook/addon-actions: ^7.0.21 => 7.0.21
    @storybook/addon-console: ^2.0.0 => 2.0.0
    @storybook/addon-docs: ^7.0.21 => 7.0.21
    @storybook/addon-essentials: ^7.0.21 => 7.0.21
    @storybook/addon-interactions: ^7.0.21 => 7.0.21
    @storybook/addon-links: ^7.0.21 => 7.0.21
    @storybook/addon-mdx-gfm: ^7.0.21 => 7.0.21
    @storybook/addons: ^7.0.21 => 7.0.21
    @storybook/mdx1-csf: ^1.0.0 => 1.0.0
    @storybook/node-logger: ^7.0.21 => 7.0.21
    @storybook/preset-create-react-app: ^7.0.21 => 7.0.21
    @storybook/react: ^7.0.21 => 7.0.21
    @storybook/react-webpack5: ^7.0.21 => 7.0.21
    @storybook/testing-library: ^0.1.0 => 0.1.0
    @storybook/theming: ^7.0.21 => 7.0.21

Additional context

0edd67e8-38ca-470f-95db-1d91e2ca712c

shilman commented 1 year ago

Hi @luked177, this is an interesting issue. Try the following workaround instead:

module.exports = {
    ...
    webpack: (config, options) => {
        options.cache.set = () => Promise.resolve();
        return config;
    }
};

We no longer have a managerWebpack API in SB7, but it looks like the workaround has nothing to do with webpack really and is just disabling the cache object, which is locking up on your machine somehow.

The underlying issue probably still exists & if you provide a reproduction we'd be happy to take a look at it. Go to https://storybook.new or see repro docs. Thank you! 🙏

EffectivelyEfficient commented 1 year ago

I have a similar issue.

Expected Behavior To run through npx storybook@latest init and npm run storybook on a new project and have something work. As documented on https://storybook.js.org/docs/react/get-started/install

Actual results Similar error thrown to this case as shown in Appendix One

Unfeasible work around Opening Windows Security and disabling real-time protection will allow storybook to start. Re-enabling real-time protection will cause the problem to occur again. This is not feasible, as NPM packages should not be automatically trusted. It would be nice if Storybook waited a short moment for the file to be no longer locked

Interim work around Putting in the following code, works around the problem. However, caching is a desired feature, so this is only an interim solution module.exports = { ... webpack: (config, options) => { options.cache.set = () => Promise.resolve(); return config; } };

Appendix One

`10% building 0/1 entries 0/0 dependencies 0/0 modulesnode:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: EBUSY: resource busy or locked, open 'C:\xxxxx\node_modules\.cache\storybook\dev-server\a5a8bf6e622aef57065c6498611f40c911543d7d-a21314dc303cf26dabba6bf4a8fd381e47e44e94'] {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'open',
  path: 'C:\\xxxxx\\node_modules\\.cache\\storybook\\dev-server\\a5a8bf6e622aef57065c6498611f40c911543d7d-a21314dc303cf26dabba6bf4a8fd381e47e44e94'`