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.

Infinite loading when refreshing the page in NextJS

See original GitHub issue

Describe the bug

Hello @kettanaito I add msw to nextjs with server side rendering, which make hot reloading in Nextjs not work.

I tested and saw that at my local, when editting code then waiting it display on screen, but not. I have to Ctrl + f5. If it’s lucky it will show up, otherwise the machine will hang with the words ‘waiting for existing socket’ .

But when I close tab and open new tab, it’s ok, But that’s really inconvenient, if I comment require(‘…/mocks’) in _app.js file. It’s oke

Environment

  • msw: 0.26.1
  • nodejs: 12.18.2
  • npm: 6.14.5

Version chrome: 88.0.4324.104

To Reproduce

Link repo: https://codesandbox.io/s/serverless-fog-mex0z?file=/package.json:352-358

Screenshots

If applicable, add screenshots to help explain your problem. image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jedfostercommented, Apr 22, 2021

I don’t think this is fully fixed. I’m seeing infinite refresh behavior in my own next.js app, same as I was seeing in the OP’s sandbox. My app uses msw v0.28.1, so I forked the OP’s sandbox and updated to the latest msw, v0.28.2, and still see this behavior.

Environment

msw: 0.28.2 nodejs: 12.18.2 npm: 6.14.6

Chrome: 89.0.4389.114

To Reproduce

Code Sandbox: https://codesandbox.io/s/busy-water-u8u1d Standalone web view: https://u8u1d.sse.codesandbox.io/

Open the Chrome dev tools and refresh the result web view pane and it may go into an infinite refresh loop. You will definitely see the loop if you open the standalone web view in a new window.

This is how I have my dev tools configured:

Screen Shot 2021-04-22 at 15 39 01

It’s entirely possible I’m simply doing service workers wrong, but if so, please provide some documentation on how the dev tools should be configured for working with msw.

Happy to open a new ticket if necessary.

0reactions
squalvjcommented, Mar 24, 2022

lmao i got this infinite loop while running in the server side using Next.JS with graphql, i solved it by removing unecessary data that outside the requested query, and it solve my infinite loop.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js - Loading doesn't turn off when refreshing page
It works just fine unless I refresh the page. The loading doesn't become 0 (false) when I refresh the page. When I change...
Read more >
Basic Features: Fast Refresh - Next.js
Next.js ' Fast Refresh is a new hot reloading experience that gives you instantaneous feedback on edits made to your React components.
Read more >
Fetch data from Next.js API and create an infinite loading list ...
Check out https://screencasts.alterclass.io/ for more episodes!▻ Learn to build your own production-ready React applications and become a ...
Read more >
500 Internal Server Error, using Next.js Causing Refresh ...
On the / page it's just not loading anything from our app. So weird and getting these errors on the console.
Read more >
location.reload() - Web APIs | MDN
You may, though, come across instances of location.reload(true) in existing code that was written with the assumption the force-reload effect ...
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