question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Program never ends when `actions` given on MacOS

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
jackkinsellacommented, Aug 13, 2019

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.

0reactions
jackkinsellacommented, Aug 15, 2019

OK have done: https://github.com/facebook/jest/pull/8831

Nice working with you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Loading Revision" never ends | Apple Developer Forums
After my app builds, "Loading Revision" with a spinner shows up and never seems to end. A Stackoverflow says to delete a certain...
Read more >
How to stop Finder action on Mac - Setapp
Stop Finder action with Terminal · Go > Utilities > Terminal. Alternatively, you can also press Command + Space to launch Spotlight, type...
Read more >
How to use MacBook with lid closed - Macworld
Here's how to stop your MacBook sleeping when the lid is closed ; Open System Settings. Click Lock Screen. ; Go to System...
Read more >
Step through the program | IntelliJ IDEA Documentation
Stepping is the process of controlling step-by-step execution of the program. IntelliJ IDEA provides a set of stepping actions, which are used depending...
Read more >
Keyboard mappings using a PC keyboard on a Macintosh
The following are typical Windows keyboard shortcuts and their Macintosh equivalents that apply to the operating system. System Shortcuts. Action. Windows.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found