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.

Slow requests for non-mocked resources

See original GitHub issue

Describe the bug

In our app, we use segment.io for analytics, and in some cases it will take 30 seconds to load the analytics code during a mocked request from msw in Cypress.

any ideas on how to stop this from happening? or just tell msw to not touch any requests it doesn’t mock?

Environment

  • msw: 0.0.0
  • nodejs: 0.0.0
  • npm: 0.0.0

Please also provide your browser version.

To Reproduce

Steps to reproduce the behavior:

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
hwstovallcommented, Nov 14, 2020

I just wanted to follow-up on this and say that I was able to isolate the issue down to Axios running under Jest. I updated my code to use node-fetch and it works as intended. I feel like this is more related to other Axios-specific issues that have already been discussed, so I think it’s safe to consider this unrelated to the original issue.

2reactions
hwstovallcommented, Nov 11, 2020

@lifeiscontent, I wanted to mention that I’m seeing this when I attempt to test an Express application with Jest.

When I run the server normally, both mocked and non-mocked requests are quick. However, something about running them in Jest seems to cause them to go incredibly slow or even timeout. I will put together a basic repo to recreate this, but I wanted to go ahead and mention that I’m seeing this outside of Cypress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python requests is slow and takes very long to complete HTTP ...
First, try logging · If you only need to check if the server is up, try a HEAD or streaming request · For...
Read more >
Laravel's safety mechanisms - PlanetScale
A comprehensive overview of Laravel's many safety features that can help you prevent painful mistakes.
Read more >
Automating safe, hands-off deployments - Amazon AWS
Pipeline sources. Pipelines at Amazon automatically validate and safely deploy any type of source change to production, not only changes to application code....
Read more >
Best practices for Web application maintenance
We make sure that our tests do not depend on a non mocked API that could slow down their execution. During the E2E...
Read more >
You are mocking it wrong. - DEV Community ‍ ‍
It is slower, it allocates more, and it's wrong. ... so treat each test as a 'request' and let the DI container to...
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