@@ -45,6 +45,7 @@ const assert = require('internal/assert');
45
45
const EE = require ( 'events' ) ;
46
46
const Stream = require ( 'stream' ) ;
47
47
const internalUtil = require ( 'internal/util' ) ;
48
+ const { kIsWritable } = require ( 'internal/streams/utils' ) ;
48
49
const { kOutHeaders, utcDate, kNeedDrain } = require ( 'internal/http' ) ;
49
50
const { Buffer } = require ( 'buffer' ) ;
50
51
const {
@@ -88,6 +89,7 @@ const kCorked = Symbol('corked');
88
89
const kUniqueHeaders = Symbol ( 'kUniqueHeaders' ) ;
89
90
const kBytesWritten = Symbol ( 'kBytesWritten' ) ;
90
91
const kEndCalled = Symbol ( 'kEndCalled' ) ;
92
+ const kErrored = Symbol ( 'errored' ) ;
91
93
92
94
const nop = ( ) => { } ;
93
95
@@ -146,11 +148,30 @@ function OutgoingMessage() {
146
148
147
149
this . _keepAliveTimeout = 0 ;
148
150
149
- this . _onPendingData = nop ;
151
+ this [ kErrored ] = null ;
150
152
}
151
153
ObjectSetPrototypeOf ( OutgoingMessage . prototype , Stream . prototype ) ;
152
154
ObjectSetPrototypeOf ( OutgoingMessage , Stream ) ;
153
155
156
+ ObjectDefineProperty ( OutgoingMessage . prototype , kIsWritable , {
157
+ get ( ) {
158
+ // TODO (ronag): w.ended?
159
+ return ! this . destroyed && ! this [ kErrored ] && ! this . finished ;
160
+ }
161
+ } ) ;
162
+
163
+ ObjectDefineProperty ( OutgoingMessage . prototype , 'errored' , {
164
+ get ( ) {
165
+ return this [ kErrored ] ;
166
+ }
167
+ } ) ;
168
+
169
+ ObjectDefineProperty ( OutgoingMessage . prototype , 'closed' , {
170
+ get ( ) {
171
+ return this . _closed ;
172
+ }
173
+ } ) ;
174
+
154
175
ObjectDefineProperty ( OutgoingMessage . prototype , 'writableFinished' , {
155
176
__proto__ : null ,
156
177
get ( ) {
@@ -320,6 +341,8 @@ OutgoingMessage.prototype.destroy = function destroy(error) {
320
341
}
321
342
this . destroyed = true ;
322
343
344
+ this [ kErrored ] = error ;
345
+
323
346
if ( this . socket ) {
324
347
this . socket . destroy ( error ) ;
325
348
} else {
0 commit comments