} else {
process.nextTick(function() { req.oncomplete(); });
}
- } else if (!swallowErrors) {
- const ex = errnoException(err, 'write');
- if (typeof callback === 'function') {
- process.nextTick(callback, ex);
- } else {
- this.emit('error', ex); // FIXME(bnoordhuis) Defer to next tick.
+ } else {
+ // Cleanup handle on error
+ if (obj && obj.postSend)
+ obj.postSend(handle);
+
+ if (!swallowErrors) {
+ const ex = errnoException(err, 'write');
+ if (typeof callback === 'function') {
+ process.nextTick(callback, ex);
+ } else {
+ this.emit('error', ex); // FIXME(bnoordhuis) Defer to next tick.
+ }
}
}