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.

Using MSW with Next.js causes stopping HMR/Fast Refresh

See original GitHub issue

Describe the bug

Using MSW with Next.js causes stopping HMR/Fast Refresh because of unclosed SSE connections.

Environment

  • msw: 0.26.2
  • nodejs: 14.14.0
  • yarn: 2.4.1
  • Browser: Chromium 89.0.4389.82

To Reproduce

Steps to reproduce the behavior:

  1. Clone https://github.com/tkamenoko/msw-nextjs-hmr .
  2. Install deps: yarn .
  3. Start dev server: yarn dev .
  4. Open localhost:3000 in your browser.
  5. Show Network tab in DevTools.
  6. Click rendered links, and you will find that SSE connections between MSW and the dev server are not closed.
  7. After the number of connections reaches the limit, HMR will not work.
  8. Reload the page, but it will not complete: Waiting for available sockets

Expected behavior

A browser should receive changes and refresh the page. SSE connections between MSW and the dev server should be closed when connections between browser and MSW are closed.

Issue Analytics

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

github_iconTop GitHub Comments

13reactions
khw1031commented, May 11, 2021

Having the same Issue

  • msw v0.28.2
  • next v10.1.2
11reactions
saintwinklecommented, Mar 25, 2021

@kettanaito I think what @tkamenoko and I mean is that this issue is tracking HMR issue, not the solved cookies issue which maybe not related to this one.😂 So we can still discuss here.

I’ve created a simpler repo to reproduce the issue: https://github.com/saintwinkle/with-msw-next-app .

And here’s the process:

https://user-images.githubusercontent.com/4580163/112440392-3720df00-8d85-11eb-9646-9b8df73879ef.mov

If i’m missing something, let me know. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fearless demos, controlled tests: Next.js & MSW tutorial
Take your demos and tests to the next level, by bringing in Mock Service Worker!Are you nervous doing live demos because you always...
Read more >
How to mock server responses in useEffect using MSW.js (5/6)
NextJS & Tests : How to mock server responses in useEffect using MSW.js (5/6). Watch later. Share. Copy link. Info. Shopping. Tap to...
Read more >
Next.js : Refresh page after modifying a file, without rerunning ...
I have to stop the npm script, rerun the "npm run xxx" command, then refresh the browser. It's kind of time consuming. Is...
Read more >
A curated list of awesome things related to Vite.js - Morioh
In this library, we will learn about Awesome Vite.js: A Curated List Of Awesome ... Redux Toolkit, RTK Query, TailwindCSS, MSW, Jest, React...
Read more >
Full text of "Mount Sinai Journal of Medicine" - Internet Archive
The leading reasons for using the emergency response system were falls and chest ... even further the promotion of health as a means...
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