-
-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSE Bypass for HMR #834
Comments
Hey, @takefumi-yoshii. Thank you for reporting and investigating this! Do you think this may be the root cause for #785 and #788? I was mistaken to believe that Service Worker cannot intercept SSE, but that's not the case. Looks like we'd have to bypass such requests for now, at least until #156 lands. Please, would you be interested in opening a pull request with your fix? |
I feel that both are related, but I can't reply without reproduce environment.
Of course! I hope it helps until it is fundamentally resolved. |
I've tried these steps to reproduce using Can I try something else to reproduce this issue? Edit: what triggers the |
So the issue is, in fact, related to how MSW processed repeatedly established SSE from webpack. Looks like webpack HMR has some logic that triggers SSE whenever you come back to the application's tab in the browser. It'd be nice to find that logic in their source code and see how we can emulate it in a test suite. We do run tests in an automated Chromium, so we can switch from/to the tab without issues. That won't trigger SSE by default, though. I suspect there's some logic on webpack's side that does that. |
I also reproduced it with NextJS usage example .It happened when repeated tab switching.I also look for the relevant part of webpack. |
The most reliable way to test this will be to apply |
I'd rather find out more about why eventsource gets disconnected. I wonder if there's any reason we can introspect? I'm quite content with the fix you've provided, to bypass any |
Okay, I've set up a basic WebpackDevServer with HMR and can see it is enabled in the browser:
However, no |
Analyzing NextJSHere's where the evtSource = getEventSourceWrapper({
path: `${assetPrefix}/_next/webpack-hmr?page=${currentPage}`,
timeout: 5000,
}) The server-side of NextJS just bypasses this route:
It appears that the SSE established is not coming from webpack but from NextJS. Huh, so there's no straightforward way to put this in an integration test in this repo. |
Describe the bug
When developing on the Next.js with
next dev
, No problem for a while,but suddenly the server becomes unresponsive.
Environment
msw: 0.29.0
nodejs: 14.16.0
npm: 0.0.0
next: 10.2.3
Chrome: Version 91.0.4472.164 (Official Build) (x86_64)
To Reproduce
Steps to reproduce the behavior:
next dev
Expected behavior
Server always responds.
Screenshots
The below capture is the Network tab when no response is returned.
Workaround
It looks like there is a problem in
webpack-hmr?page=xxxx
.As a workaround, I added the below SSE Bypass in generated
mockServiceWorker.js
.Then, I was able to solve the problem that the response did not come back.
This Bypass is useful to us, but what do you think?
The text was updated successfully, but these errors were encountered: