fix: [M3-7177] - Fix MSW not always intercepting API calls#9717
Conversation
mjac0bs
left a comment
There was a problem hiding this comment.
🙌🏼 I tested this on various pages and with various refreshes and saw the MSW intercepting requests every time. When I walked through the DC pricing changes, there were no issues we saw earlier with the regions endpoint sometimes not being intercepted correctly and not returning the mocked region data from cached regions we would expect.
Thank you for fixing!
types is intercepted by the MSW:

regions is intercepted by the MSW and includes the expected cached region data:


|
@mjac0bs and I talked this over and we think that that it is expected behavior for the preview link to exclude |
|
Tested and looks good! thanks for the fix. Confirmed locally ✅ And yes, can confirm the cache gets overridden. If you run a production build locally you'll get the same problem 👍 |



Description 📝
Sometimes, with the MSW on, you load the app and some API calls don't get properly intercepted and the real API responds with data. I think this is because the MSW is not always being initialized before our app loads.
I think this use to not be an issue, but I think #9525 made it so that the MSW gets enabled later than it use to, causing this race condition.
This PR brings back some logic from #9525 (but using async/await instead of a callback) that will load dev tools before we render the app.
Major Changes 🔄
How to test 🧪
Note
This seemed to be like a race condition so it is hard to reproduce the bug or verify the fix works