Node can crash while doing a put because of missing 'error' handler
See original GitHub issueHello,
We are seeing the possibility for a crash of node when doing a put.
Here is the stack trace:
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:111:27)
...
Emitted 'error' event at:
at Socket.<anonymous> (/usr/src/app/node_modules/ssh2/lib/client.js:307:10)
at Socket.emit (events.js:198:13)
at Socket.EventEmitter.emit (domain.js:448:20)
...
at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.
error Command failed.
Exit code: 1
In terms of things we have looked at, we see that the SFTPWrapper will emit an error: https://github.com/mscdex/ssh2/blob/master/lib/SFTPWrapper.js#L15-L16
Do we need to add an error handler to the sftp object here in addition to the stream?
https://github.com/theophilusx/ssh2-sftp-client/blob/master/src/index.js#L449-L453
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
Let It Crash: Best Practices for Handling Node.js Errors on ...
When a JavaScript error is not properly handled, an uncaughtException is emitted. These suggest the programmer has made an error, and they ...
Read more >Best Practices for Node.js Error-handling - Toptal
The best way to deal with these errors is to crash immediately and restart gracefully with an automatic restarter like PM2—the reason being...
Read more >Why does my app keep crashing through a faulty error handler ...
I guess you forgot to wrap your code inside a try-catch block. Since you are throwing an error, but it is never caught...
Read more >A Comprehensive Guide To Error Handling In Node.js
An error in Node.js is any instance of the Error object. ... it becomes an uncaught exception, which may cause your application to...
Read more >Error handling in node.js. Even with the most experienced…
Another example could be missing to put a comma or colon in the object. Whenever any of these errors are encountered in your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Forgot to mention that if you are able to make any progress, I am more than happy to accept pull requests which address the issue.
Sorry, I should have included more code earlier. I’m calling that
transferFile
method this way:And what we are seeing during the crash is that the first
Transferring...
log is output, but then nothing (we see evidence of a crash right afterwards). We don’t see the log that indicates a success, nor do we see the log that indicates a failure.