GithubHelp home page GithubHelp logo

Comments (7)

weblancaster avatar weblancaster commented on September 27, 2024 2

In my case, I do see [MSW] Mocking enabled. and the first server request is mocked but none of the consequent calls.

I have been trying to replicate this issue:

I was not able to replicate the failed to fetch error but my local code the issue still persists

from msw.

kettanaito avatar kettanaito commented on September 27, 2024 1

I'm going to close this. Next.js doesn't work well with MSW at the moment. Until I have a fully functional example as confirmation of that, Next.js is not supported.

You can follow the progress of that example here:
mswjs/examples#101

The Next.js team has also reached out to me to help address the remaining issues on Next.js side, so I hope to post some updates soon.

from msw.

Fallsleep avatar Fallsleep commented on September 27, 2024

in my case, most time every request is ok when I login by form in the page, there's no request before I typing username/password and click to send the first request after msw mocked.

If I refresh the page after login, there's a request for getting user info when vue router navigation, I'll got the same error, the request is send soon after msw mocked. the following login out request is successed.

I try to downgrade to 2.0.14, erveything is ok.

btw, if set onUnhandledRequest to bypass, it only thrown axios error, change to warn, it may thrown msw error sometime.

from msw.

dylano avatar dylano commented on September 27, 2024

I'm seeing the same issue with with [email protected] on a React+Vite app. MSW does not appear to be initialized for the requests which are fired off as part of the initial page load.

This sort of looks like the symptoms reported in #1653 but the deferred render approach is not effective here as it was in 2.0.14.

Edit: The bug was mine -- I'm running fine with 2.1.2 now. The snippet in the deferred render comment linked above is missing an await on the worker.start() and that carried over to my code. Perhaps 2.0.14 is just slightly quicker to start and didn't affect my app in the same way despite not waiting on the start call.

from msw.

tunganh-phamba avatar tunganh-phamba commented on September 27, 2024

same problem for me as well in version 2.1.2

from msw.

weblancaster avatar weblancaster commented on September 27, 2024

In my case, I do see [MSW] Mocking enabled. and the first server request is mocked but none of the consequent calls.

I have been trying to replicate this issue:

I was not able to replicate the failed to fetch error but my local code the issue still persists

@kettanaito I was able to replicate in the codesandbox links above, wherein the first load MSW intercepts the first call but after I refresh the browser, there is no more interception.

from msw.

weblancaster avatar weblancaster commented on September 27, 2024

For future reference found this post from @kettanaito on X

In summary, this is the state of Next.js + MSW right now:

  • Server-side mocking is possible but your app won't pick up updates to the handlers unless you restart it;
  • Client-side mocking is not possible.

https://twitter.com/kettanaito/status/1749496339556094316

from msw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.