File tree 2 files changed +7
-7
lines changed
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -116,10 +116,7 @@ class WebSocket extends EventEmitter {
116
116
get bufferedAmount ( ) {
117
117
if ( ! this . _socket ) return this . _bufferedAmount ;
118
118
119
- //
120
- // `socket.bufferSize` is `undefined` if the socket is closed.
121
- //
122
- return ( this . _socket . bufferSize || 0 ) + this . _sender . _bufferedBytes ;
119
+ return this . _socket . _writableState . length + this . _sender . _bufferedBytes ;
123
120
}
124
121
125
122
/**
Original file line number Diff line number Diff line change @@ -208,12 +208,15 @@ describe('WebSocket', () => {
208
208
wss . on ( 'connection' , ( ws ) => {
209
209
const data = Buffer . alloc ( 1024 , 61 ) ;
210
210
211
- while ( ws . _socket . bufferSize === 0 ) {
211
+ while ( ws . bufferedAmount === 0 ) {
212
212
ws . send ( data ) ;
213
213
}
214
214
215
- assert . ok ( ws . _socket . bufferSize > 0 ) ;
216
- assert . strictEqual ( ws . bufferedAmount , ws . _socket . bufferSize ) ;
215
+ assert . ok ( ws . bufferedAmount > 0 ) ;
216
+ assert . strictEqual (
217
+ ws . bufferedAmount ,
218
+ ws . _socket . _writableState . length
219
+ ) ;
217
220
218
221
ws . on ( 'close' , ( ) => wss . close ( done ) ) ;
219
222
ws . close ( ) ;
You can’t perform that action at this time.
0 commit comments