Skip to content
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

Chrome unregisters MSW after 5 mins of inactivity / idle on MSW Examples Repo #1744

Closed
4 tasks done
jkinger opened this issue Sep 18, 2023 · 3 comments
Closed
4 tasks done
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser

Comments

@jkinger
Copy link

jkinger commented Sep 18, 2023

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 14 or higher

Browsers

Chromium (Chrome, Brave, etc.)

Reproduction repository

https://github.com/mswjs/examples/tree/master/examples/rest-react

Reproduction steps

  1. Follow the "Getting Started" guide in the Readme of https://github.com/mswjs/examples/tree/master/examples/rest-react
  2. Run yarn start
  3. Using Chrome, open the localhost URL.
  4. Once opened, leave the browser tab open in the background without any user activity for at least 5 minutes and ensure DevTools is not open (this is important).
  5. Come back after 5 minutes and try to hit the submit button.

Current behavior

Nothing happens when the submit button is pressed because Chrome unregistered the MSW from inactivity.

Expected behavior

With the KeepAlive addition (Issue 367), I would assume the submit button would still work correctly even after an elapsed time of inactivity passes.

@jkinger jkinger added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser labels Sep 18, 2023
@kettanaito
Copy link
Member

Hi, @jkinger. Thanks for submitting this.

We have a ping/pong messaging in place to prevent this behavior. I wonder if that messaging happens in your case or if it's related to something else.

Can you please confirm your version of msw by running npm ls msw in your project?

@jkinger
Copy link
Author

jkinger commented Sep 18, 2023

When I ran npm ls msw it gave the following:

└─┬ rest-react-example@0.0.0 -> ./examples/rest-react
  └── msw@0.20.3 invalid: "latest" from examples/rest-react

I fixed the package to be "msw": "^1.3.1" and confirmed with npm ls msw (below):

└─┬ rest-react-example@0.0.0 -> ./examples/rest-react
  └── msw@1.3.1

Re-ran npx msw init public and confirmed that /examples/rest-react/public/mockServiceWorker.js was also reflecting the new version as well.

I then ran through the above "Reproduction steps" again and was unable to reproduce now so closing.

If any takeaways can be gathered from this it might be the MSW Example repo could use some updating but I'm sure there are bigger fish to fry.

Thanks all!

@jkinger jkinger closed this as completed Sep 18, 2023
@jkinger jkinger changed the title Chrome unregisters MSW after 5 mins of inactivity / idle Chrome unregisters MSW after 5 mins of inactivity / idle on MSW Examples Repo Sep 18, 2023
@kettanaito
Copy link
Member

@jkinger, I'm glad to hear you've resolved it! The latest tag can get confusing with pre-1.0 releases, I know.

If any takeaways can be gathered from this it might be the MSW Example repo could use some updating but I'm sure there are bigger fish to fry.

That's true! In fact, we already have an updated version of examples at https://github.com/mswjs/examples-new. It's going to replace the current examples for MSW 1.0 in the near future.

Keep on building!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser
Projects
None yet
Development

No branches or pull requests

2 participants