Duplicate log output and MaxListenersExceededWarning warning (regression in 0.47.1)
See original GitHub issuePrerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn’t contain the answer to my issue
Environment check
- I’m using the latest
msw
version - I’m using Node.js version 14 or higher
Browsers
Chromium (Chrome, Brave, etc.), Firefox
Reproduction repository
https://github.com/kleinfreund/kuma-gui/tree/feat/rework-dataplanes-view
Reproduction steps
- In package.json, change the msw dependency from
0.47.0
to^0.47.3
- Run
yarn install
- Run
yarn run dev
- Browse around the UI and observe the console log entries
Current behavior
Many redundant log entries appear for requests that are only made once (and handled once). Example:
RestHandler.ts:183 [MSW] 09:08:29 GET http://localhost:5681/ (200 OK)
The following warning appears:
events.js:46 MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 response:mocked listeners added. Use emitter.setMaxListeners() to increase limit
at _addListener (http://localhost:8080/node_modules/.vite/deps/msw.js?v=9b1b86e7:597:19)
at StrictEventEmitter2.addListener (http://localhost:8080/node_modules/.vite/deps/msw.js?v=9b1b86e7:608:14)
at StrictEventEmitter2.once (http://localhost:8080/node_modules/.vite/deps/msw.js?v=9b1b86e7:868:36)
at Object.onMockedResponse (http://localhost:8080/node_modules/.vite/deps/msw.js?v=9b1b86e7:22101:34)
ProcessEmitWarning @ events.js:46
_addListener @ events.js:219
addListener @ events.js:227
StrictEventEmitter2.once @ StrictEventEmitter.js:34
onMockedResponse @ createRequestListener.ts:76
await in onMockedResponse (async)
handleRequest @ handleRequest.ts:127
await in handleRequest (async)
(anonymous) @ createRequestListener.ts:34
(anonymous) @ setupWorker.ts:93
Expected behavior
The logs aren’t unnecessarily redundant and there is no max listeners exceeding warning.
Notes
- Likely cause as the only change between 0.47.0 and 0.47.1: https://github.com/mswjs/msw/pull/1392
- Initially reported in https://github.com/mswjs/msw/issues/1343#issuecomment-1246566445
- Code that reproduces the issue does not import msw/node
Issue Analytics
- State:
- Created a year ago
- Reactions:10
- Comments:7 (6 by maintainers)
Top Results From Across the Web
fix: remove duplicate response logging in the browser console ...
Update strict-event-emitter version that to resolve log duplicates. Fixes Duplicate log output and MaxListenersExceededWarning warning (regression in 0.47.1) # ...
Read more >Possible EventEmitter memory leak detected. 11 message lis ...
I've received this warning many times, but usually only for two ... if ( 'MaxListenersExceededWarning' == err.name ) { console.log('o ...
Read more >rollup changelog
Fix a situation where invalid code was rendered when dynamically importing a module with synthetic named exports when preserving modules (#3738) ...
Read more >Actions execution throws "MaxListenersExceededWarning"
After enabling multiple Actions of the same trigger, I started getting warnings on the Realtime Webtask Log extension, specifically:.
Read more >griebnitz/node_modules/rollup/CHANGELOG.md - GitLab
Fix a severe performance regression when the same module is imported by a lot of ... #3575: Handle some cases of duplicate export...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@snaka, that must have been the root cause. We’ve just merged and released the fix to
strict-event-emitter
. Would anyone be interested in bumping that dependency in MSW in a pull request?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
strict-event-emitter
is a fantastic place to start!@snaka That looks promising considering that https://github.com/mswjs/msw/pull/1392 introduced calls to
context.emitter.once
.