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

This lib breaks storybook with wp5 #407

Closed
AdrianDiazG opened this issue Jun 23, 2024 · 4 comments
Closed

This lib breaks storybook with wp5 #407

AdrianDiazG opened this issue Jun 23, 2024 · 4 comments

Comments

@AdrianDiazG
Copy link

AdrianDiazG commented Jun 23, 2024

Issue

I get infinite calls to webpack hmr

It's been impossible to implement this library with storybook and wp5, I've tried implementing a loader myself, I tried the loader from msw-storybook-addon, I also tried with a wrapper component and start-stop the worker on mount/unmount with useEffect, I tried with an empty serviceWorder, no handlers, also tried setting the scope option for the worker. It seems that no matter what, when worker.start is called I get errors and ifinite calls, this is beyond me and I can't find any related documentation anywhere

this is what I get infinitely, this also seems to hapen on storybook reload, not in the first load

image

context:

versions:

"msw": "^2.3.1",
"msw-storybook-addon": "^2.0.2",
"storybook": "^8.1.1",
"webpack": "^5.75.0",
@kettanaito
Copy link
Member

Hi, @AdrianDiazG.

Can you please share the errors you get? Above is some logging that doesn't come from MSW.

I shouldn't need any custom loaders to use MSW with Storybook. The docs in https://github.com/mswjs/msw-storybook-addon should be enough. Happy to help once you provide more details or, ideally, a reproduction repo. Thanks.

@AdrianDiazG
Copy link
Author

AdrianDiazG commented Jun 23, 2024

thanks for the quick response @kettanaito, well, that's the thing I don't get any errors, just infinite calls when I execute worker.start or initialize in the case of the addon, however I'm not making any calls in my components, the only line I have in the worker right now is console.log('mockServiceWorker started') which I see on the first load (which doesn't produce infinite calls) but as soon as it hot reloads or if I manually reload the page, I don't see the "mockServiceWorker started" message (which is expected I think) but it makes these infinite calls, no error messages. If you could give me a hint on what additional details I could give you, I'd be happy to get on it

@AdrianDiazG
Copy link
Author

It actually seems to be this same issue:

but I tried the solutions proposed unsuccessfully :(

@AdrianDiazG
Copy link
Author

I think I finally solved it. I realized that the problem was gone if I toggled the "bypass for network" option for the service worker on developer tools, so I used the msw-storybook-addon's initialize like this:

initialize({
  serviceWorker: {
    options: {
      updateViaCache: 'none'
    }
  }
})

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

No branches or pull requests

2 participants