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

Hot reloading is intercepted by fetch-mock #18702

Closed
shiraze opened this issue Jul 13, 2022 · 1 comment
Closed

Hot reloading is intercepted by fetch-mock #18702

shiraze opened this issue Jul 13, 2022 · 1 comment

Comments

@shiraze
Copy link

shiraze commented Jul 13, 2022

Describe the bug
I use fetch-mock to provide mock data for components being displayed in Storybook. There were no issues hot reloading when we were using storybook v6.4.18.
In the upgrade to v6.5.9 we now get the following error when hot reloading due to a code change:

runtime~main.iframe.bundle.js:1246 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'reduce')
    at __webpack_require__.hmrC.jsonp (jsonp chunk loading:507:1)
    at hot module replacement:265:1
    at Array.reduce (<anonymous>)
    at hot module replacement:261:1

I've tracked this down to HMR using fetch to get updates and instead of getting the data it expects, it's getting my mock data, and this is because I had a "catch-all" fetch mock:

fetchMock.get("*", getMyResults);

Unfortunately, when I have explicit URLs set in my mock I then get an error similar to the following:

fetch-mock: No fallback response defined for GET to /runtime_main.97720ca8e7a584b047a2.hot-update.json

To Reproduce
I'll try set up a reproduction, but I just want to get this out to the community in case they're also facing the same issue when upgrading.
Also, I've raised here, rather than against fetch-mock, or HMR, because the change to how hot reloading works in Storybook would cause previously working stories to now fail in a way which can be really confusing.

Please create a reproduction by running npx sb@next repro and following the instructions. Read our documentation to learn more about creating reproductions.
Paste your repository and deployed reproduction here. We prioritize issues with reproductions over those without.

System
Please paste the results of npx sb@next info here.

Additional context
Add any other context about the problem here.

@shiraze
Copy link
Author

shiraze commented Jul 13, 2022

This is a duplicate of wheresrhys/fetch-mock#618, where a solution is provided.

@shiraze shiraze closed this as completed Jul 13, 2022
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

1 participant