MaxListenersExceededWarning - Angular 15 #1688
Replies: 1 comment
-
|
Hi @i-am-the-arm , DiagnosisI know your question was quite a while ago. I just ran into this same warning myself for the first time when building out a suite of unit tests. I'm new to msw, but my story might help you (or others finding this thread). To better understand what's going on, check the details of the warning to see if there is a specific listener that is the culprit. In my case, it was all the I know that in the docs for msw it states "You are unlikely to use this API directly while developing or testing with MSW". I don't know how often people actually need to peek into the server events to see what's going on, but I suspect that it should be infrequent. (My situation was unique...) FixThe solution for my situation was to clear out the listener after each test: afterEach(() => {
server.events.removeAllListeners();
server.resetHandlers();
});RnDHere are some possible articles to deepen your understanding of the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I wanted to get some additional information on how this warning is generated:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 response:mocked listeners added. Use emitter.setMaxListeners() to increase limitI have a page that makes several independent api requests on load and seems to throw this warning when this happens. When I only have 1 or 2 requests, this warning goes away. Can anyone explain how
mswhandles or adds listeners?mswwarning or does it come from the underlying framework?mswcreate new listeners for every request that's made? (i.e., if I have 15 api requests, should I expect to have 15 listeners; even if the same endpoint is called more than once?)Ultimately, I just want to ensure there's not a concern of memory leaks but wasn't sure where to look to validate.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions