last day (15 days later) » 

9:14 AM
8
Q: How Node.js silently crashes without any information?

LEQADAApplication silently dies when it opens a lot of SFTP connections. I use all sorts of process event handlers and the only one triggered is process.on('exit',... I'm using an npm package for SFTP ssh2-sftp-client which is using ssh2 package underneath. Here is a minimal reproducible code const ...

 
what are you trying to accomplish with that loop? That does not look correct.
 
I have an application which dies the same way. Of course in that application I close what I open. This code is a Minimal, Reproducible Example of the problem. So that anyone can copy the code, run it and see the issue.
 
Someone is calling process.exit
 
But the while loop makes no sense to me. I'd like to know what you are trying to accomplish with it. It looks like the wrong design that could exhaust all network resources.
 
@BenjaminGruenbaum I literally checked all the dependencies of dependencies. There is no process.exit anywhere. Unless some internal Node.js code is doing that.
@jfriend00 the issue is usually not happening on the first try. One has to run it multiple times. My assumption is at one point server cuts off the connections. That is why I have an infinite loop there. Again, it is an example and not a production code.
 
9:14 AM
Take a core dump and check :)
 
@BenjaminGruenbaum --abort-on-uncaught-exception will not work here because there is not exception. Is there a way to make a core dump on exit code 0? What is the best way to do it?
 
But the loop keeps calling sftpClient.connect() over and over again forever. The loop never stops, not even upon a successful connection. Can't possibly be the right design and could easily be a source of resource problems. I see the library has its own retry options which are better designed.
 
@jfriend00 I'm sorry for confusion. The question is not about coding style. The code in the question is an example of a strange behavior of Node.js that I'm trying to understand. The problem itself I think is not related to the fact that there is an opening connection in an infinite loop. But if it is related then I'd like to know how.
 
As I said already, you may be exhausting some kind of resource. When unexplained things are happening, I fix any clearly wrong code first and retest.
 
@jfriend00 the problem is the SFTP I'm using gets consumed by a lot of different applications. None of them of course don't keep connections opened. And none of them is opening connections in an infinite loop. SFTP server gets under pressure and some of the applications crash exactly as the example in the question. I understand your point but my issue is not an infinite loop. Consider it as a PoC that Node can fail silently. Mystery, right?
 
9:14 AM
There was this open issue in the github repo for something that looks very similar to your problem. A possible fix is to make sure you have node +8 and the latest version of the module since they don't seem to know what is/was causing this.
 
@TudorConstantin this is exactly what I'm experiencing. But on Node.js 12 and the latest version of the package. Added this info to the question. Thank you for the issue.
 
have a look at this code section in the ssh2 js module. Add some extra messages in your installed version of it and see whether that's the crash source...
 
@TudorConstantin I added a message in the onExit function and didn't get any output on crash :(
 
try adding messages as the first line in all of the on... functions, even in the onReady() (to make sure these messages are shown)
 
@TudorConstantin Yes, I already add a message on all .emit calls this library and down till the ssh2-streams. I see the messages but it doesn't help.
 
9:14 AM
and what's the last message shown before node crashes?
 
@TudorConstantin the last msg I can get so far is from github.com/mscdex/ssh2/blob/…
created an issue in the repository github.com/theophilusx/ssh2-sftp-client/issues/168
 
I think this is better discussed on github not here. VTC as too broad
 
@Liam protest! The question is clear. It is about the Node.js behaviour. Nothing broad.
 
There are 23 comments on this question.....That's too many
 
@Liam 23 comments, because there is no one who can answer. It doesn't make the question too broad.
 

last day (15 days later) »