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.

Receiving stale data intermittently even after overriding endpoint and resetting handlers

See original GitHub issue

Environment

Name Version
msw 0^0.24.2
node 14.15
OS Mac OS Catalina 10.15.7

Request handlers

I have created a new project to reproduce this issue: https://github.com/NickLewry/next-msw-swr

Current behavior

Currently I am being served the default handler response in my 2nd test even though I am overriding that response with server.use(). Weirdly this issue has proved to be intermittent as occasionally the override will work and the tests will pass. Another strange observation is if I move the override server.use() to the first test then I am served that response in my 2nd test even though I am calling server.resetHandlers() after each test.

initially I thought it had to do with SWR caching the response so I implemented the cache.clear() after each test which has not solved the issue and I also double checked the cache was empty at the beginning of the 2nd test by logging out cache.keys(). I then also wrote a Wrapper component for <SWRConfig> setting the dedupeInterval to 0 as I thought requests were getting grouped but I don’t think that is the case.

This is an intermittent issue:

  1. If you run the tests for the first time they will pass, but as soon as you run them again immediately after (or have watch mode enabled and trigger multiple reruns by saving) you will see a failure as the wrong data is being served by the handler.

Expected behavior

I would expect the override to work in my second test by serving the updated content and for the handlers to be reset after each test.

Screenshots

N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
NickLewrycommented, Apr 29, 2021

Also @kettanaito I love this library so thanks so much for working on it 💯

2reactions
kettanaitocommented, Apr 29, 2021

It’s users like you who motivate the entire team to keep improving MSW, @NickLewry. Thank you for being a part of our journey!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetWitness Platform Known Issues - 571872
Components Found In / Exists In Tracking Number Endpoint 12.1 ASOC‑125096 Source Server 12.1 SADOCS‑124473 Health & Wellness 11.5.x, 11.6.x 11.7.1.x, 12.0.x SADOCS‑2330
Read more >
Apache Kafka Reference Guide - Quarkus
This reference guide demonstrates how your Quarkus application can utilize SmallRye Reactive Messaging to interact with Apache Kafka. 1. Introduction. Apache ...
Read more >
RFC 4960: Stream Control Transmission Protocol
1. Slow-Start Beginning data transmission into a network with unknown conditions or after a sufficiently long idle period requires SCTP to probe the...
Read more >
use() - Api - Mock Service Worker Docs
Request handler override can be used to handle only the next matching request. After a one-time request handler has been used, it never...
Read more >
Spring Data REST Reference Guide
3. Getting started. Spring Data REST is itself a Spring MVC application and is designed in such a way that it should integrate...
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