Only add process handlers if graceful cleanup requested#125
Only add process handlers if graceful cleanup requested#125chrisprice wants to merge 1 commit intoraszi:masterfrom
Conversation
|
Just realised I misinterpreted the expected functionality, I don't think the warning I'm seeing is fixable by this module. |
|
@chrisprice I am curious how this error came to. Can you provide me with a link to the sources? |
|
@chrisprice Thanks. I just tried this out and at first, I did see the same error when running Jest in watch mode. After the fourth run of all test suites, the error would show up. I then modified node_modules/selenium-webdriver/node_modules/tmp to log some output to the console, including the array of exit listeners. Turns out that this array is always empty before tmp installs its listeners, so this does not seem to be related to or even caused by tmp. I then removed the node_modules directory and ran npm install again. |
|
Thanks for having a play around with this. I must admit, I'm now more confused! My understanding was that Jest runs each spec file in it's own module context such that any local state in modules is lost between different spec files and different runs of the same spec file. However, listeners added to global modules are outside the scope of the module context and are therefore carried across between different spec files and different runs of the same spec file. Based on that model, your first 3 paragraphs make sense but I'm very confused by why it worked in the last paragraph... FWIW I'm happy with the fix that I have for now, if it causes a problem in the future I'll be sure to ping this thread with the solution or at least a more detailed description of the problem... Thanks again! |
|
@chrisprice jest uses child processes to run each test suite in parallel unless you run them "in band". As for the module context, I think that tmp should know when it already installed its handlers so that it will not install them multiple times. I am currenty trying to think up a possible way to accomplish this. |
|
@chrisprice found a solution to the problem. However, this requires that dependent other projects must update their package.json in order to make use of the new functionality and prevent tmp from installing its handlers multiple times. |
I was running into MaxListenersExceededWarning when running Jest tests which referenced this module. I'm new to the project but after a quick look I think the change is safe.