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.

Changes to handlers for node is not being picked up by live reload

See original GitHub issue

Prerequisites

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:open
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vietanhtran16commented, Sep 20, 2022

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 in getServerSideProps) and https://my.backend/user (called when clicking on Load Reviews => request to API Routes => which calls https://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 Kapture 2022-09-21 at 11 48 13

0reactions
chrisb2244commented, Oct 19, 2022

@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') in initMocks or similar), but it doesn’t actually change the behaviour of the handlers (easily exhibited by putting a console.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.

Read more comments on GitHub >

github_iconTop 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 >

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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found