-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Describe the bug
When one tries to connect to non-existing ftp server - unhanded exception happens.
This happens because of trying to send command this.send("QUIT") on uninitialized socket.
Once this type of socket error happen one cannot catch error with regular try{} catch(e){} locally where error happens.
At that point you can handle them only by using:
process.on("uncaughtException", ...
Example code
try
{
// connect to FTP server
let response = await ftpClient.access({
host: ftpHost,
port: ftpPort,
user: ftpUser,
password: ftpPassword
})
} catch(e){
// never reaches this in case of error
}
Console output
Caught exception: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:399:19)
at writeOrBuffer (_stream_writable.js:387:5)
at Socket.Writable.write (_stream_writable.js:318:11)
at FTPContext.send (/opt/tvmid/core/node_modules/basic-ftp/dist/FtpContext.js:179:22)
at FTPContext.closeWithError (/opt/tvmid/core/node_modules/basic-ftp/dist/FtpContext.js:69:14)
at Socket. (/opt/tvmid/core/node_modules/basic-ftp/dist/FtpContext.js:308:18)
at Object.onceWrapper (events.js:421:26)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'ERR_STREAM_DESTROYED'
Which version of Node.js are you using?
Node 12, Node 16
Additional context
Non accessible server address is used - forcing to generate error.