-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Duplicate log output and MaxListenersExceededWarning warning (regression in 0.47.1) #1411
Comments
Just want to confirm this exact issue is affecting our app too. Unable to share the full code unfortunately. Ours is a Vite app running on React 18 and this issue started after bumping to 0.47.1.
const prepare = async (): Promise<ServiceWorkerRegistration | void> => {
if (!import.meta.env.PROD) {
const { default: worker } = await import('../stubs/browser');
return worker.start({
onUnhandledRequest: ({ url }, print) => {
if (!url.pathname.includes(window.config.orchestration.url)) {
return;
}
print.warning();
},
});
}
return Promise.resolve();
};
prepare().then(() => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<BrandProvider>
<ThemeProvider>
<GlobalStyle />
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<App />
</BrowserRouter>
</QueryClientProvider>
</ThemeProvider>
</BrandProvider>
</React.StrictMode>
);
});
/**
* This file configures the mock service worker if the app is not running in PRODUCTION mode.
*/
import { SetupWorkerApi, rest, setupWorker } from 'msw';
import handlers from './handlers';
let wrk: SetupWorkerApi = {} as SetupWorkerApi;
if (!import.meta.env.PROD) {
// Configure a Service Worker with the given request handlers
wrk = setupWorker(...handlers);
// @ts-ignore: store msw on window to access it in functional-test
window.msw = {
worker: wrk,
rest,
};
}
export default wrk; |
Perhaps the cause is ? |
@snaka, that must have been the root cause. We've just merged and released the fix to On a related note, I've noticed that https://github.com/open-draft/strict-event-emitter is heavily under-tested. If you'd like to contribute to a package we use extensively in MSW and beyond, writing tests for |
I'm not sure, but is this how you want it? |
In case you’re running into this issue and have trouble avoiding it because you’re regenerating your lock file, you might need to pin a couple of dependencies to prevent them from being updated to a version either observes this issue or an artifact of #1407: When using yarn, you can pin the dependencies in your package.json file like so: {
"// explanation for overriding msw": "https://github.com/mswjs/msw/issues/1411",
"// explanation for overriding @mswjs/interceptors": "https://github.com/mswjs/msw/pull/1407",
"// explanation for overriding headers-polyfill": "https://github.com/mswjs/msw/pull/1407",
"resolutions": {
"msw": "0.47.0",
"msw/@mswjs/interceptors": "0.17.4",
"msw/headers-polyfill": "3.0.4"
}
} Something like this can be done for npm as well using the |
Released: v0.47.4 🎉This has been released in v0.47.4! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Prerequisites
Environment check
msw
versionBrowsers
Chromium (Chrome, Brave, etc.), Firefox
Reproduction repository
https://github.com/kleinfreund/kuma-gui/tree/feat/rework-dataplanes-view
Reproduction steps
0.47.0
to^0.47.3
yarn install
yarn run dev
Current behavior
Many redundant log entries appear for requests that are only made once (and handled once). Example:
The following warning appears:
Expected behavior
The logs aren't unnecessarily redundant and there is no max listeners exceeding warning.
Notes
The text was updated successfully, but these errors were encountered: