Closed stephan-noel-primer closed 3 days ago
Hey, @stephan-noel-primer. Thank you for reaching out.
I can suspect the suggestions logic in MSW that can be the culprit here. Whenever there's an unhandled request, MSW looks up a list of suggested request handlers to account for typos and method/operation kind mismatches to improve the DX. This can be an expensive operation given a large number of handlers.
Your approach above is sensible. Perhaps we should consider disabling the handler suggestions as an option if that's proven to be the performance bottleneck. To debug this, I recommend forking MSW, removing the suggestions, linking it to the msw-storybook-addon
and using its local built to see if there's any performance impact.
MSW has long stopped shipping js-lavenshtein
for request handler suggestions. Using onUnhandledRequest
does not affect MSW performance now.
Problem
Execution of visual tests on Chromatic goes from 3 minutes on average to around 18 minutes
Changing the following code:
to simply:
fixed the issue.
I'm not sure if the problem is with this addon, with msw itself, or with how the integration is being done. If I want to workaround this and provide a fallback request handler to setupServer, I can't because there is no way to forward options to setupServer.
Version info:
msw-storybook-addon: 1.1.0 msw: 0.30.0: