File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -137,3 +137,30 @@ const Countdown = require('../common/countdown');
137137 req . destroy ( ) ;
138138 } ) ) ;
139139}
140+
141+ // test close before connect
142+ {
143+ const server = h2 . createServer ( ) ;
144+
145+ server . on ( 'stream' , common . mustNotCall ( ) ) ;
146+ server . listen ( 0 , common . mustCall ( ( ) => {
147+ const client = h2 . connect ( `http://localhost:${ server . address ( ) . port } ` ) ;
148+ const socket = client [ kSocket ] ;
149+ socket . on ( 'close' , common . mustCall ( ( ) => {
150+ assert ( socket . destroyed ) ;
151+ } ) ) ;
152+
153+ const req = client . request ( ) ;
154+ // should throw goaway error
155+ req . on ( 'error' , common . expectsError ( {
156+ code : 'ERR_HTTP2_GOAWAY_SESSION' ,
157+ type : Error ,
158+ message : 'New streams cannot be created after receiving a GOAWAY'
159+ } ) ) ;
160+
161+ client . close ( ) ;
162+ req . resume ( ) ;
163+ req . on ( 'end' , common . mustCall ( ) ) ;
164+ req . on ( 'close' , common . mustCall ( ( ) => server . close ( ) ) ) ;
165+ } ) ) ;
166+ }
You can’t perform that action at this time.
0 commit comments