@@ -197,7 +197,6 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
197
197
const handle = new tcp_wrap . TCP ( tcp_wrap . constants . SOCKET ) ;
198
198
const req = new tcp_wrap . TCPConnectWrap ( ) ;
199
199
const sreq = new stream_wrap . ShutdownWrap ( ) ;
200
- const wreq = new stream_wrap . WriteWrap ( ) ;
201
200
testInitialized ( handle , 'TCP' ) ;
202
201
testUninitialized ( req , 'TCPConnectWrap' ) ;
203
202
testUninitialized ( sreq , 'ShutdownWrap' ) ;
@@ -206,20 +205,25 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
206
205
handle . close ( ) ;
207
206
} ) ;
208
207
209
- wreq . handle = handle ;
210
- wreq . oncomplete = common . mustCall ( ( ) => {
211
- handle . shutdown ( sreq ) ;
212
- testInitialized ( sreq , 'ShutdownWrap' ) ;
213
- } ) ;
214
- wreq . async = true ;
215
-
216
- req . oncomplete = common . mustCall ( ( ) => {
217
- // Use a long string to make sure the write happens asynchronously.
208
+ req . oncomplete = common . mustCall ( writeData ) ;
209
+ function writeData ( ) {
210
+ const wreq = new stream_wrap . WriteWrap ( ) ;
211
+ wreq . handle = handle ;
212
+ wreq . oncomplete = ( ) => {
213
+ handle . shutdown ( sreq ) ;
214
+ testInitialized ( sreq , 'ShutdownWrap' ) ;
215
+ } ;
218
216
const err = handle . writeLatin1String ( wreq , 'hi' . repeat ( 100000 ) ) ;
219
217
if ( err )
220
218
throw new Error ( `write failed: ${ getSystemErrorName ( err ) } ` ) ;
219
+ if ( ! wreq . async ) {
220
+ testUninitialized ( wreq , 'WriteWrap' ) ;
221
+ // Synchronous finish. Write more data until we hit an
222
+ // asynchronous write.
223
+ return writeData ( ) ;
224
+ }
221
225
testInitialized ( wreq , 'WriteWrap' ) ;
222
- } ) ;
226
+ }
223
227
req . address = common . localhostIPv4 ;
224
228
req . port = server . address ( ) . port ;
225
229
const err = handle . connect ( req , req . address , req . port ) ;
0 commit comments