@@ -195,7 +195,6 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
195
195
const handle = new tcp_wrap . TCP ( tcp_wrap . constants . SOCKET ) ;
196
196
const req = new tcp_wrap . TCPConnectWrap ( ) ;
197
197
const sreq = new stream_wrap . ShutdownWrap ( ) ;
198
- const wreq = new stream_wrap . WriteWrap ( ) ;
199
198
testInitialized ( handle , 'TCP' ) ;
200
199
testUninitialized ( req , 'TCPConnectWrap' ) ;
201
200
testUninitialized ( sreq , 'ShutdownWrap' ) ;
@@ -204,20 +203,25 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
204
203
handle . close ( ) ;
205
204
} ) ;
206
205
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
+ } ;
216
214
const err = handle . writeLatin1String ( wreq , 'hi' . repeat ( 100000 ) ) ;
217
215
if ( err )
218
216
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
+ }
219
223
testInitialized ( wreq , 'WriteWrap' ) ;
220
- } ) ;
224
+ }
221
225
req . address = common . localhostIPv4 ;
222
226
req . port = server . address ( ) . port ;
223
227
const err = handle . connect ( req , req . address , req . port ) ;
0 commit comments