Get DST WriteStream is resolved before writeStream is done
See original GitHub issueHi, I’m using the latest version 7.2.0 but I’m not able to use the file right away after DST. My workaround for now is to add sleep/timeout function to wait for around 500ms before using the file, but I don’t want to do this because I don’t know how long it’ll take for bigger files. Please see my code below:
try {
const sftp = new Client()
await sftp.connect(sftpConfig)
const writeStream = gcsBucket.file(path).createWriteStream() // GCS bucket writeStream
const data = await sftp.get(sftpPath, writeStream)
/* // Work around
const timeout = () => new Promise(resolve => setTimeout(resolve, 500))
await timeout() */
} catch (error) {
....
} finally {
await sftp.end()
}
- ssh2-sftp-client 7.2.0
- Node version 14.0.0
- Windows
I also tried downgrading to 7.1.0 and 7.0.4 but none of them work. Please help. Thank you.
[Note: ] I was previously using version 6.0.1 and never had this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
event associated with fs.createWriteStream in node.js
Main issue is - createWriteStream is not finished [due to whatever reasn] - by the time the async function that contains it -...
Read more >How to know when writeStream is completed? #147 - GitHub
I need to know when a createWriteStream has fully completed. I tried on events for end, finish and unpipe and all of them...
Read more >Structured Streaming Programming Guide - Apache Spark
To do that, you have to use the DataStreamWriter (Scala/Java/Python docs) returned through Dataset.writeStream() . You will have to specify one or more...
Read more >Getting Started with Node Streams - CODE Magazine
createReadStream('test.txt'); const writeStream = fs. ... Note that the event listener is wired up before calling the Pipe method.
Read more >Node.js fs.createWriteStream() Method - GeeksforGeeks
The createWriteStream() method is an inbuilt application programming interface of fs module which allows to quickly make a writable stream ...
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
Have updated code to resolve on finish rather than close event for the write stream. Let me know if this resolves your issue.
OK, I will push a new version to npmjs.com tomorrow.