@@ -39,7 +39,6 @@ const runSymbol = Symbol("run");
39
39
const deferredSymbol = Symbol ( "deferred" ) ;
40
40
const eofInProgress = Symbol ( "eofInProgress" ) ;
41
41
const fakeSocketSymbol = Symbol ( "fakeSocket" ) ;
42
- const finishedSymbol = Symbol ( "finished" ) ;
43
42
const firstWriteSymbol = Symbol ( "firstWrite" ) ;
44
43
const headersSymbol = Symbol ( "headers" ) ;
45
44
const isTlsSymbol = Symbol ( "is_tls" ) ;
@@ -677,14 +676,14 @@ Object.defineProperty(Server, "name", { value: "Server" });
677
676
function onRequestEvent ( event ) {
678
677
const [ server , http_res , req ] = this . socket [ kInternalSocketData ] ;
679
678
680
- if ( ! http_res [ finishedSymbol ] ) {
679
+ if ( ! http_res . finished ) {
681
680
switch ( event ) {
682
681
case NodeHTTPResponseAbortEvent . timeout :
683
682
this . emit ( "timeout" ) ;
684
683
server . emit ( "timeout" , req . socket ) ;
685
684
break ;
686
685
case NodeHTTPResponseAbortEvent . abort :
687
- http_res [ finishedSymbol ] = true ;
686
+ http_res . finished = true ;
688
687
this . destroy ( ) ;
689
688
break ;
690
689
}
@@ -1542,7 +1541,7 @@ function OutgoingMessage(options) {
1542
1541
Stream . $call ( this , options ) ;
1543
1542
1544
1543
this . sendDate = true ;
1545
- this [ finishedSymbol ] = false ;
1544
+ this . finished = false ;
1546
1545
this [ headerStateSymbol ] = NodeHTTPHeaderState . none ;
1547
1546
this [ kAbortController ] = null ;
1548
1547
@@ -1714,15 +1713,15 @@ const OutgoingMessagePrototype = {
1714
1713
} ,
1715
1714
1716
1715
get writableNeedDrain ( ) {
1717
- return ! this . destroyed && ! this [ finishedSymbol ] && this [ kBodyChunks ] && this [ kBodyChunks ] . length > 0 ;
1716
+ return ! this . destroyed && ! this . finished && this [ kBodyChunks ] && this [ kBodyChunks ] . length > 0 ;
1718
1717
} ,
1719
1718
1720
1719
get writableEnded ( ) {
1721
- return this [ finishedSymbol ] ;
1720
+ return this . finished ;
1722
1721
} ,
1723
1722
1724
1723
get writableFinished ( ) {
1725
- return this [ finishedSymbol ] && ! ! ( this [ kEmitState ] & ( 1 << ClientRequestEmitState . finish ) ) ;
1724
+ return this . finished && ! ! ( this [ kEmitState ] & ( 1 << ClientRequestEmitState . finish ) ) ;
1726
1725
} ,
1727
1726
1728
1727
_send ( data , encoding , callback , byteLength ) {
@@ -1850,7 +1849,7 @@ function ServerResponse(req, options) {
1850
1849
this . _sent100 = false ;
1851
1850
this [ headerStateSymbol ] = NodeHTTPHeaderState . none ;
1852
1851
this [ kPendingCallbacks ] = [ ] ;
1853
- this [ finishedSymbol ] = false ;
1852
+ this . finished = false ;
1854
1853
1855
1854
// this is matching node's behaviour
1856
1855
// https://github.com/nodejs/node/blob/cf8c6994e0f764af02da4fa70bc5962142181bf3/lib/_http_server.js#L192
@@ -1887,13 +1886,6 @@ const ServerResponsePrototype = {
1887
1886
this [ headerStateSymbol ] = value ? NodeHTTPHeaderState . sent : NodeHTTPHeaderState . none ;
1888
1887
} ,
1889
1888
1890
- get finished ( ) {
1891
- return this [ finishedSymbol ] ;
1892
- } ,
1893
- set finished ( value ) {
1894
- this [ finishedSymbol ] = value ;
1895
- } ,
1896
-
1897
1889
// This end method is actually on the OutgoingMessage prototype in Node.js
1898
1890
// But we don't want it for the fetch() response version.
1899
1891
end ( chunk , encoding , callback ) {
@@ -2074,11 +2066,11 @@ const ServerResponsePrototype = {
2074
2066
} ,
2075
2067
2076
2068
get writableNeedDrain ( ) {
2077
- return ! this . destroyed && ! this [ finishedSymbol ] && ( this [ kHandle ] ?. bufferedAmount ?? 1 ) !== 0 ;
2069
+ return ! this . destroyed && ! this . finished && ( this [ kHandle ] ?. bufferedAmount ?? 1 ) !== 0 ;
2078
2070
} ,
2079
2071
2080
2072
get writableFinished ( ) {
2081
- return ! ! ( this [ finishedSymbol ] && ( ! this [ kHandle ] || this [ kHandle ] . finished ) ) ;
2073
+ return ! ! ( this . finished && ( ! this [ kHandle ] || this [ kHandle ] . finished ) ) ;
2082
2074
} ,
2083
2075
2084
2076
get writableLength ( ) {
@@ -2227,7 +2219,7 @@ function ensureReadableStreamController(run) {
2227
2219
for ( let run of this [ runSymbol ] ) {
2228
2220
run ( controller ) ;
2229
2221
}
2230
- if ( ! this [ finishedSymbol ] ) {
2222
+ if ( ! this . finished ) {
2231
2223
const { promise, resolve } = $newPromiseCapability ( GlobalPromise ) ;
2232
2224
this [ deferredSymbol ] = resolve ;
2233
2225
return promise ;
@@ -2280,7 +2272,7 @@ function ServerResponse_finalDeprecated(chunk, encoding, callback) {
2280
2272
chunk = Buffer . from ( chunk , encoding ) ;
2281
2273
}
2282
2274
const req = this . req ;
2283
- const shouldEmitClose = req && req . emit && ! this [ finishedSymbol ] ;
2275
+ const shouldEmitClose = req && req . emit && ! this . finished ;
2284
2276
if ( ! this . headersSent ) {
2285
2277
let data = this [ firstWriteSymbol ] ;
2286
2278
if ( chunk ) {
@@ -2300,7 +2292,7 @@ function ServerResponse_finalDeprecated(chunk, encoding, callback) {
2300
2292
}
2301
2293
2302
2294
this [ firstWriteSymbol ] = undefined ;
2303
- this [ finishedSymbol ] = true ;
2295
+ this . finished = true ;
2304
2296
this . headersSent = true ; // https://github.com/oven-sh/bun/issues/3458
2305
2297
drainHeadersIfObservable . $call ( this ) ;
2306
2298
this [ kDeprecatedReplySymbol ] (
@@ -2318,7 +2310,7 @@ function ServerResponse_finalDeprecated(chunk, encoding, callback) {
2318
2310
return ;
2319
2311
}
2320
2312
2321
- this [ finishedSymbol ] = true ;
2313
+ this . finished = true ;
2322
2314
ensureReadableStreamController . $call ( this , controller => {
2323
2315
if ( chunk && encoding ) {
2324
2316
chunk = Buffer . from ( chunk , encoding ) ;
@@ -2464,13 +2456,13 @@ function ClientRequest(input, options, cb) {
2464
2456
}
2465
2457
2466
2458
if ( chunk ) {
2467
- if ( this [ finishedSymbol ] ) {
2459
+ if ( this . finished ) {
2468
2460
emitErrorNextTickIfErrorListenerNT ( this , $ERR_STREAM_WRITE_AFTER_END ( "Cannot write after end" ) , callback ) ;
2469
2461
return this ;
2470
2462
}
2471
2463
2472
2464
write_ ( chunk , encoding , null ) ;
2473
- } else if ( this [ finishedSymbol ] ) {
2465
+ } else if ( this . finished ) {
2474
2466
if ( callback ) {
2475
2467
if ( ! this . writableFinished ) {
2476
2468
this . on ( "finish" , callback ) ;
@@ -2484,7 +2476,7 @@ function ClientRequest(input, options, cb) {
2484
2476
this . once ( "finish" , callback ) ;
2485
2477
}
2486
2478
2487
- if ( ! this [ finishedSymbol ] ) {
2479
+ if ( ! this . finished ) {
2488
2480
send ( ) ;
2489
2481
resolveNextChunk ?.( true ) ;
2490
2482
}
@@ -2503,7 +2495,7 @@ function ClientRequest(input, options, cb) {
2503
2495
res . _dump ( ) ;
2504
2496
}
2505
2497
2506
- this [ finishedSymbol ] = true ;
2498
+ this . finished = true ;
2507
2499
2508
2500
// If request is destroyed we abort the current response
2509
2501
this [ kAbortController ] ?. abort ?.( ) ;
@@ -2614,7 +2606,7 @@ function ClientRequest(input, options, cb) {
2614
2606
self . emit ( "drain" ) ;
2615
2607
}
2616
2608
2617
- while ( ! self [ finishedSymbol ] ) {
2609
+ while ( ! self . finished ) {
2618
2610
yield await new Promise ( resolve => {
2619
2611
resolveNextChunk = end => {
2620
2612
resolveNextChunk = undefined ;
@@ -2725,7 +2717,7 @@ function ClientRequest(input, options, cb) {
2725
2717
let handleResponse = ( ) => { } ;
2726
2718
2727
2719
const send = ( ) => {
2728
- this [ finishedSymbol ] = true ;
2720
+ this . finished = true ;
2729
2721
const controller = new AbortController ( ) ;
2730
2722
this [ kAbortController ] = controller ;
2731
2723
controller . signal . addEventListener ( "abort" , onAbort , { once : true } ) ;
@@ -2978,7 +2970,7 @@ function ClientRequest(input, options, cb) {
2978
2970
// this.useChunkedEncodingByDefault = true;
2979
2971
// }
2980
2972
2981
- this [ finishedSymbol ] = false ;
2973
+ this . finished = false ;
2982
2974
this [ kRes ] = null ;
2983
2975
this [ kUpgradeOrConnect ] = false ;
2984
2976
this [ kParser ] = null ;
@@ -3148,7 +3140,7 @@ const ClientRequestPrototype = {
3148
3140
} ,
3149
3141
3150
3142
get writable ( ) {
3151
- return ! this [ finishedSymbol ] ;
3143
+ return ! this . finished ;
3152
3144
} ,
3153
3145
} ;
3154
3146
0 commit comments