Program never ends when `actions` given on MacOS
See original GitHub issueI noticed that when running the jest unit testing library with --watch --notify
(which calls node-notifier
), my CPU usage soon went up to 90%, due to multiple instances of node-notifier
hanging around. There are a couple of other people with the same issue over on in the jest repo.
Here’s an example process that was spinning:
./myapp/node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier -actions Run again,Exit tests -closeLabel "Close" -message "-&M-T️ 1 of 29 tests failed" -title "4% Failed" -ap
I experimented around with the node-notifier
library’s API and noticed that if I passed the same configuration options to node-notifier
as jest
does, the program never ends. To see what I mean, run the following in a stand-alone program. You’ll notice it displays the notification but the program keeps running indefinitely.
// reproduceIssue.js
// Usage: node reproduceIssue.js
const notifier = require('node-notifier')
notifier.notify(
{
actions: [ 'Run again', 'Exit tests' ],
closeLabel: 'Close',
message: '⛔️ 1 of 9 tests failed',
title: '12% Failed'
}, () => {}
)
However, when I removed the actions
attribute, the program ends after the notification is shown. I could also get the program to end, even with actions, by adding an explicit timeout
attribute:
const notifier = require('node-notifier')
notifier.notify(
{
actions: [ 'Run again', 'Exit tests' ],
closeLabel: 'Close',
// new code
timeout: 5,
// end new code
message: '⛔️ 1 of 9 tests failed',
title: '12% Failed'
}, () => {}
)
So my question is — is this indefinite running while awaiting an action expected behavior? If so, I’ll make a PR in jest
. If not, then I’ll wait for an update to this library.
Attached is a log of a single iteration of the repeated system calls. system-calls.log
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Yep adding a
timeout
to the watch mode in jest makes good sense to me!The puzzling thing, which seems unrelated to either code-base, is why the
terminal-notifier
in macOS is such a CPU hog.OK have done: https://github.com/facebook/jest/pull/8831
Nice working with you 😃