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.

error with cache when running storybook

See original GitHub issue

Sometimes when running the storybook, breaks and only works after removing the cache

error

ERR! SyntaxError: app/node_modules/.cache/storybook/dev-server/325c8f456729b912b0d2134054eb7448-41ac79ddc5290d504ad69ef1fe8200a7: Unexpected end of JSON input
ERR!     at JSON.parse (<anonymous>)
ERR!     at app/node_modules/file-system-cache/node_modules/jsonfile/index.js:36:18
ERR!     at app/node_modules/graceful-fs/graceful-fs.js:123:16
ERR!     at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
ERR!  SyntaxError: app/node_modules/.cache/storybook/dev-server/325c8f456729b912b0d2134054eb7448-41ac79ddc5290d504ad69ef1fe8200a7: Unexpected end of JSON input
ERR!     at JSON.parse (<anonymous>)
ERR!     at app/node_modules/file-system-cache/node_modules/jsonfile/index.js:36:18
ERR!     at app/node_modules/graceful-fs/graceful-fs.js:123:16
ERR!     at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)

    WARN Broken build, fix the error above.
    WARN You may need to refresh the browser.

command used to remove all cache

find . -name ".cache" -type d -prune -exec rm -rf '{}' +

System

Environment Info:

  System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
  Binaries:
    Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
    Yarn: 1.22.10 - ~/Documents/projects/app/node_modules/.bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.16.3/bin/npm
  Browsers:
    Chrome: 88.0.4324.96
    Firefox: 83.0
    Safari: 14.0.2
  npmPackages:
    @storybook/addon-actions: 6.1.14 => 6.1.14 
    @storybook/addon-console: 1.2.2 => 1.2.2 
    @storybook/addon-docs: 6.1.14 => 6.1.14 
    @storybook/addon-essentials: 6.1.14 => 6.1.14 
    @storybook/addon-knobs: 6.1.16 => 6.1.16 
    @storybook/addon-links: 6.1.14 => 6.1.14 
    @storybook/addon-storyshots: 6.1.14 => 6.1.14 
    @storybook/addon-storysource: 6.1.14 => 6.1.14 
    @storybook/react: 6.1.14 => 6.1.14 
    @storybook/storybook-deployer: 2.8.7 => 2.8.7 

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

80reactions
mrichmondcommented, Feb 4, 2021

I’m able to temporarily resolve this with:

rm -rf node_modules/.cache/storybook

…and then it works again… until it doesn’t.

12reactions
andrewigginscommented, Jul 22, 2022

I ran into the same issue (the Error: EBUSY: resource busy or locked, open '\storybook-test\node_modules.cache\storybook\dev-server\325c8f456729b912b0d2134054eb7448-41ac79ddc5290d504ad69ef1fe8200a7 one) today as well. Consistently reproduced for me and a team member preventing Storybook from running for us.

After digging into it a bit, it appears this line in progress-reporting.ts is causing the error: https://github.com/storybookjs/storybook/blob/bf98ade4ca2067ddd23dfbf4cd65e19b889fa9ea/lib/core-common/src/utils/progress-reporting.ts#L52

I suspect that this method is hammering the file system and either overloading it or Windows Defender is stepping in due to “suspicious” file system hammering or something 🤷‍♂️

I was able to work around this in a pretty hacky way, but it did enable me to run storybook. In my project’s .storybook/main.ts file, I added a function to customize the managerWebpack and set cache.set to a no-op:

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

Perhaps a better workaround would be an option to disable all caching in case future uses of the cache cause similar issues. A real fix might be to update progress-reporting to hammer the file system less (perhaps debouncing or throttling?) or rework progress-reporting to not rely on file system at all if possible.

Cheers! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "Cannot GET /” when running Storybook
If you have ever run Storybook successfully but got "Cannot GET /” display in the browser? There is a simple fix for this...
Read more >
Fail to load storybook everytime - Stack Overflow
https://support.aspnetzero.com/QA/Questions/11057/Error-EBUSY-resource-busy-or-locked-when-running-npm-run-create-bundles.
Read more >
CLI options - Storybook
The flag --no-manager-cache disables the internal caching of Storybook and can severely impact your Storybook loading time, so only use it when you...
Read more >
I've updated my storybook, why can't I see the changes?
If you have already viewed your live storybook before, whether on desktop or mobile, your storybook has been cached by your browser.
Read more >
How to solve Jest storybook test error “cannot ... - agirl.codes
How to solve Jest storybook test error “cannot find interopRequireDefault.js”. Tuesday, 22 Febuary 2022 ... This clears the cache without running the test....
Read more >

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 Hashnode Post

No results found