You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
It's super annoying, that errors don't contain a stacktrace.
{ Error: ENOENT: no such file or directory, open '/repo_2017-09-01T1213/keywords'
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/repo_2017-09-01T1213/keywords' }
They contain absolutely no helpful information.
Is there a way to fix this?
Well, there is a memory dump when you cause a segfault in NodeGit or libgit2. It comes in the form of disassembly, though, so if you are not keen on parsing through pointer information they don't often help much. You can glean some info from them, however.
As for your concern, we generate errors directly from libgit2, so the error you see is simply the returned error code and error message from the libgit2 routine that we invoked via NodeGit. There isn't really a "stack trace" as you know it. You run one method at a time from NodeGit, so if you get an error you should be able to deduce where it is coming from with a little work.
That is all of the information we receive back from libgit2 so there isn't much else we can give you.
If you want to try and get a stack trace yourself, you can try using something like this to manually grab a trace from libgit2. Although, I have never done that so I cannot speak for its effectiveness.
I think the issue here is that it's not at all obvious where the error is coming from in a long promise chain given the (mostly) asynchronous nature of NodeGit.
If libgit2 doesn't provide a stack trace of C functions, can NodeGit not provide a stack trace of JavaScript functions?
We might be able to add some code to our generators to, at the very least, return what routine threw the error. I would need to look at the code that generates the async functions again, but I feel like that minimal solution might not be too bad to implement. What do you think of something like appending the function name to the error as some property, like err.errorFunction? I don't want to call it a stack, because it isn't. @implausible any thoughts?
Yeah that "solution" has been a verbally discussed intent for a long time, just nobody ever had time to get to it. Super useful though, most likely, even if just to aid in bug reporting or requesting help more than in direct debugging.
@cjhoward92 For the function's name, what are you thinking of? The libgit2 C function like git_merge_base or the generated C++ function like Merge::base?
I've submitted pull request #1393 which adds a new errorFunction property to the error with a value of Merge.base (as an example) to match the JavaScript function's name.
A bit hacky but this way I'm getting nice error messages:
Error: no reference found for shorthand 'refs/remotes/origin/xmain'
at async GitScanner.pullBranch (file:///home/gg/workspaces/mieweb/wikiGDrive/src/git/GitScanner.ts:162:28)
at async Context.<anonymous> (file:///home/gg/workspaces/mieweb/wikiGDrive/test/git/RebaseTest.ts:285:7)
Activity
cjhoward92 commentedon Oct 16, 2017
Well, there is a memory dump when you cause a segfault in NodeGit or libgit2. It comes in the form of disassembly, though, so if you are not keen on parsing through pointer information they don't often help much. You can glean some info from them, however.
As for your concern, we generate errors directly from libgit2, so the error you see is simply the returned error code and error message from the libgit2 routine that we invoked via NodeGit. There isn't really a "stack trace" as you know it. You run one method at a time from NodeGit, so if you get an error you should be able to deduce where it is coming from with a little work.
That is all of the information we receive back from libgit2 so there isn't much else we can give you.
If you want to try and get a stack trace yourself, you can try using something like this to manually grab a trace from libgit2. Although, I have never done that so I cannot speak for its effectiveness.
rcjsuen commentedon Oct 16, 2017
I think the issue here is that it's not at all obvious where the error is coming from in a long promise chain given the (mostly) asynchronous nature of NodeGit.
If libgit2 doesn't provide a stack trace of C functions, can NodeGit not provide a stack trace of JavaScript functions?
cjhoward92 commentedon Oct 16, 2017
We might be able to add some code to our generators to, at the very least, return what routine threw the error. I would need to look at the code that generates the async functions again, but I feel like that minimal solution might not be too bad to implement. What do you think of something like appending the function name to the error as some property, like
err.errorFunction? I don't want to call it a stack, because it isn't. @implausible any thoughts?maxkorp commentedon Oct 18, 2017
Yeah that "solution" has been a verbally discussed intent for a long time, just nobody ever had time to get to it. Super useful though, most likely, even if just to aid in bug reporting or requesting help more than in direct debugging.
cjhoward92 commentedon Oct 19, 2017
Maybe if I get time this weekend I will draft something up. It would be helpful, I agree.
rcjsuen commentedon Oct 19, 2017
@cjhoward92 For the function's name, what are you thinking of? The libgit2 C function like
git_merge_baseor the generated C++ function likeMerge::base?cjhoward92 commentedon Oct 19, 2017
The name of the function you call from NodeGit. So
Merge::basemore likely than not.cjhoward92 commentedon Oct 19, 2017
That seems more logical to me, as we want this for debugging in JavaScript
rcjsuen commentedon Oct 28, 2017
I've submitted pull request #1393 which adds a new
errorFunctionproperty to the error with a value ofMerge.base(as an example) to match the JavaScript function's name.cjhoward92 commentedon Dec 14, 2017
Merged
ggodlewski commentedon Oct 8, 2022
I'll leave it in here In case anyone has this problem.
To fix stacktraces I created this function:
Then I wrap every nodegit call with it.
A bit hacky but this way I'm getting nice error messages: