Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
Closed
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
In case the streams errors, e.g. for a broken TCP socket, or an application error, all buffered write callbacks are never called, here is an example:
varWritable=require('stream').Writablevarinherits=require('util').inheritsfunctionMyWritable(opts){Writable.call(this,opts)}inherits(MyWritable,Writable)MyWritable.prototype._write=function(chunk,enc,done){console.log('_write',chunk.toString())setTimeout(function(){done(newError('faulty one'))},500)}varstream=newMyWritable()stream.write(newBuffer('Hello First'),'utf8',print('hello'))stream.write(newBuffer('Hello Second'),'utf8',print('second'))stream.on('error',function(err){console.log('error received',err)})functionprint(value,err){returnfunction(){console.log('done',value,err)}}Here is the output of the above program:
_write Hello First done hello [Error: faulty one] error received [Error: faulty one] The code I am using to fix this behavior is https://github.com/mcollina/aedes/blob/master/lib/client.js#L87-L91.
I am ok to submit a PR about this issue, if you think it is worth fixing.
cc @mafintosh
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.