writeStream.write callback
See original GitHub issueWhen using a write stream, the Node spec says that you can pass in a callback as last argument like this:
var ws = db.createWriteStream();
var o = {key:'k1', value: 'v1'};
ws.write(o, function() {
console.log('wrote', o);
});
I don’t need the the write stream interface to be 100% compliant, but I do need to get write acknowledges, which the current implementation does not provide.
I looked at the source code and I couldn’t find an obvious way around this (except for reimplementing the write stream on top of db.put
and db.del
, but I didn’t want to go that way).
For instance, is there any event that is emitted after a flush? I was looking at the drain
event emitted here, but I think that _writeBlock
is not always true
, so I can’t trust that, can I?
Issue Analytics
- State:
- Created 10 years ago
- Comments:44 (43 by maintainers)
Top Results From Across the Web
node.js - Can Callback for stream.write Reliably Verify That ...
The writable.write() method writes some data to the stream, and calls the supplied callback once the data has been fully handled. If an...
Read more >Stream | Node.js v19.3.0 Documentation
The 'error' event is emitted if an error occurred while writing or piping data. The listener callback is passed a single Error argument...
Read more >Node.js Stream writable.write() Method - GeeksforGeeks
The callback function is called once the data has been completely handled. Syntax: writable.write( chunk, encoding, callback).
Read more >fs.WriteStream.end JavaScript and Node.js code examples
function createApiFile(idApplication, nameDataEntity, callback) { // CREATE ROUTE FILE var ... toLowerCase() + '.js'); writeStream.write(apiTemplate); ...
Read more >WriteStream | typescript - v3.7.7
Inherited from WriteStream.constructor ... _destroy(error: Error | null, callback: function): void. Inherited from Duplex. ... Inherited from Socket.write.
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
Also, I think this thread needs an appropriate gif for write stream optimisation
@pgte Closing this because write-stream removal in 1.0.0