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.

Fails silently - not working at all

See original GitHub issue

Wrote some exploratory tests to evaluate whether to use this library. To my surprise, it just does not work at all for me.

So the issue here is twofold. Number one, it does not work, and number two, there is no meaningful output that may hint to the reason why it does not work.

describe("retrieve git history", function() {


  it.only("should retreive history", () => {
    const simpleGit = require('simple-git')();

    console.log('Have simpleGit', simpleGit, process.cwd())
    simpleGit.log({ multiLine: true }).then((gitLog)=>{
      console.log('HAVE LOG', gitLog)

    })

    simpleGit.status((cbStatus)=>{
      console.log('cbStatus', cbStatus)
    }).then((gitStatus)=>{
      console.log('GIT STATUS', gitStatus)
    })
  })

})

This results in this output:

HAVE LOG undefined
cbStatus null
GIT STATUS undefined

On OsX 10.14.6,

git --version                                                                                                                                                                                                                                                                                             Fri Dec  6 10:51:16 2019
git version 2.20.1 (Apple Git-117)

And just to be clear, git log and git status work fine in that same directory.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
steveukxcommented, Dec 6, 2019

Ah, the first should have been:

simpleGit.log({ multiLine: true }, (err, gitLog)=>{
      console.log('HAVE LOG', gitLog)
    });

    simpleGit.status((err, cbStatus)=>{
      console.log('cbStatus', cbStatus)
    });
1reaction
steveukxcommented, Dec 6, 2019

The code in your example above is using .then which is a deprecated api - in simple-git the then method runs an arbitrary function at that point of the chain, whereas in simple-git/promise it is the fulfilment handler promise generated by the step in the chain.

Please try either of these:

describe("retrieve git history", function() {

  it.only("should retrieve history", () => {
    const simpleGit = require('simple-git')();

    console.log('Have simpleGit', simpleGit, process.cwd())

    simpleGit.log({ multiLine: true }, (gitLog)=>{
      console.log('HAVE LOG', gitLog)
    });

    simpleGit.status((cbStatus)=>{
      console.log('cbStatus', cbStatus)
    });
  })

});

describe("retrieve git history", function() {

  it.only("should retrieve history", () => {
    const simpleGit = require('simple-git/promise')();

    console.log('Have simpleGit', simpleGit, process.cwd())
    simpleGit.log({ multiLine: true }).then((gitLog)=>{
      console.log('HAVE LOG', gitLog)
    });

    simpleGit.status().then((gitStatus)=>{
      console.log('GIT STATUS', gitStatus)
    });
  })

})
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle errors with grace: failing silently is not an option
Failing silently means errors can go undetected for quite a while before exploding suddenly at inconvenient and unpredictable times.
Read more >
PHP fails silently when function not defined? - Stack Overflow
I am still getting some errors but I used to get an error when I called a function that was not defined, but...
Read more >
No more silent failures! - Medium
If something unexpected happens, it will fail silently. What if I don't want to be notified for a specific exception?
Read more >
Blog - Silent Failure - Michael Tsai
Even a bad error message, something that just says “An Error Occurred” with no indication of what the error was, is better than...
Read more >
Should a program fail on errors or silently ignore them
Whether the program should fail or not depends a lot on the context. If you can handle the error gracefully, go for it....
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