Changes to handlers for node is not being picked up by live reload
See original GitHub issuePrerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn’t contain the answer to my issue
Environment check
- I’m using the latest
msw
version - I’m using Node.js version 14 or higher
Node.js version
v14.18.2
Reproduction repository
https://github.com/vercel/next.js/tree/canary/examples/with-msw
Reproduction steps
- Run
yarn dev
- Makes changes to handler for
https://my.backend/book
- Refresh the page
- Changes made to handler is not being reflected
Current behavior
In msw@0.41.1
, this version, changes made to handler was being reflected with live reload. After this version, this does not work anymore. Looks like a regression in versions after this
Expected behavior
Changes made to handler should be reflected without having to stop and start the server like in 0.41.1
version
Issue Analytics
- State:
- Created a year ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How can I add live-reload to my nodejs server - Stack Overflow
first: npm install -g nodemon. next add a script line to your package.json "live": "nodemon server.js". now when you npm live it'll live...
Read more >Node.js and Express Tutorial: Build a Website Using Pug - Auth0
Learn how to use Express and the Pug template engine to build a website in Node.js. Create user interfaces using Pug and CSS...
Read more >Live Reloading Content during Development
Live Reload is a new feature in Web Connection that can detect when you make changes to any of these types of files:....
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
In Node.js, callbacks used to be the only way asynchronous elements of your code ... Anyone using this function from elsewhere may be...
Read more >Troubleshooting XAML Hot Reload - Visual Studio (Windows)
Error indicates that the change you're attempting isn't supported by XAML Hot Reload. Stop the debugging session, make the change, and then ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @kettanaito, I have created a repo that reproduce that live reload worked with msw@0.41.1 for handlers on server side process of NextJs. That is why I think it is a regression since it used to work. Could we reopen this issue please?
Steps to reproduce:
Checkout the above branch on my fork
cd examples/with-msw/
yarn install
yarn dev
Trying changing mock response for
https://my.backend/book
(called ingetServerSideProps
) andhttps://my.backend/user
(called when clicking onLoad Reviews
=> request to API Routes => which callshttps://my.backend/user
)When you refresh the page, you should be able to see the updated mock response.
I have also attached a GIF as example
@vietanhtran16 Not in a useful way - if you do that then you can see the functions being executed again by the hot-reload (e.g. if you put some
console.log('Loading handlers')
ininitMocks
or similar), but it doesn’t actually change the behaviour of the handlers (easily exhibited by putting aconsole.log('this is a test')
in a handler, then changing the text logged - the hot-reload for Next occurs, the “Loading handlers” message appears, but triggering the MSW handler will still log the previous text (no idea why).My previous hypothesis was some sort of unused worker vs active worker, but seems like kettanaito said that wasn’t possible, and I was unable in the time since then to get any
top
running in the same instance as my processes (Docker… 😕 ). I might try with a local copy (not Docker container) and see if it’s more readily debuggable, but I don’t currently have a new hypothesis as to what’s happening.