@@ -195,7 +195,6 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
195195 const handle = new tcp_wrap . TCP ( tcp_wrap . constants . SOCKET ) ;
196196 const req = new tcp_wrap . TCPConnectWrap ( ) ;
197197 const sreq = new stream_wrap . ShutdownWrap ( ) ;
198- const wreq = new stream_wrap . WriteWrap ( ) ;
199198 testInitialized ( handle , 'TCP' ) ;
200199 testUninitialized ( req , 'TCPConnectWrap' ) ;
201200 testUninitialized ( sreq , 'ShutdownWrap' ) ;
@@ -204,20 +203,25 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
204203 handle . close ( ) ;
205204 } ) ;
206205
207- wreq . handle = handle ;
208- wreq . oncomplete = common . mustCall ( ( ) => {
209- handle . shutdown ( sreq ) ;
210- testInitialized ( sreq , 'ShutdownWrap' ) ;
211- } ) ;
212- wreq . async = true ;
213-
214- req . oncomplete = common . mustCall ( ( ) => {
215- // Use a long string to make sure the write happens asynchronously.
206+ req . oncomplete = common . mustCall ( writeData ) ;
207+ function writeData ( ) {
208+ const wreq = new stream_wrap . WriteWrap ( ) ;
209+ wreq . handle = handle ;
210+ wreq . oncomplete = ( ) => {
211+ handle . shutdown ( sreq ) ;
212+ testInitialized ( sreq , 'ShutdownWrap' ) ;
213+ } ;
216214 const err = handle . writeLatin1String ( wreq , 'hi' . repeat ( 100000 ) ) ;
217215 if ( err )
218216 throw new Error ( `write failed: ${ getSystemErrorName ( err ) } ` ) ;
217+ if ( ! wreq . async ) {
218+ testUninitialized ( wreq , 'WriteWrap' ) ;
219+ // Synchronous finish. Write more data until we hit an
220+ // asynchronous write.
221+ return writeData ( ) ;
222+ }
219223 testInitialized ( wreq , 'WriteWrap' ) ;
220- } ) ;
224+ }
221225 req . address = common . localhostIPv4 ;
222226 req . port = server . address ( ) . port ;
223227 const err = handle . connect ( req , req . address , req . port ) ;
0 commit comments