@@ -41,25 +41,29 @@ server.on('session', common.mustCall((session) => {
4141 session . on ( 'secure' , common . mustCall ( ( servername , alpn , cipher ) => {
4242 const uni = session . openStream ( { halfOpen : true } ) ;
4343
44- // TODO(@jasnell): There's still a bug in here somewhere. If we
45- // comment out the following line and close without writing
46- // anything, the test hangs.
47- uni . write ( 'hi' , common . mustCall ( ) ) ;
44+ uni . write ( 'hi' , common . expectsError ( ) ) ;
45+
46+ // TODO(@jasnell): When close is called, it will cause the write
47+ // handlers to be canceled, which results in the error that
48+ // destroys the stream. Unfortunately there's currently a bug
49+ // that does not emit that error on next tick that still needs
50+ // to be tracked down. Setting the error handler before calling
51+ // close works for now but the error should be emitted on
52+ // next tick.
53+ uni . on ( 'error' , common . mustCall ( ( ) => {
54+ assert . strictEqual ( uni . aborted , true ) ;
55+ } ) ) ;
56+
57+
58+
4859 uni . close ( 3 ) ;
4960
5061 uni . on ( 'data' , common . mustNotCall ( ) ) ;
51-
52- uni . on ( 'end' , common . mustCall ( ( ) => {
53- debug ( 'Undirectional, Server-initiated stream %d ended on server' ,
54- uni . id ) ;
55- } ) ) ;
62+ uni . on ( 'end' , common . mustNotCall ( ) ) ;
5663 uni . on ( 'close' , common . mustCall ( ( ) => {
5764 debug ( 'Unidirectional, Server-initiated stream %d closed on server' ,
5865 uni . id ) ;
5966 } ) ) ;
60- uni . on ( 'error' , common . mustCall ( ( ) => {
61- assert . strictEqual ( uni . aborted , true ) ;
62- } ) ) ;
6367
6468 debug ( 'Unidirectional, Server-initiated stream %d opened' , uni . id ) ;
6569 } ) ) ;
@@ -86,18 +90,24 @@ server.on('ready', common.mustCall(() => {
8690
8791 const stream = req . openStream ( ) ;
8892
89- stream . write ( 'hello' , common . mustCall ( ) ) ;
90- stream . close ( 1 ) ;
91-
92- stream . on ( 'end' , common . mustNotCall ( ) ) ;
93+ stream . write ( 'hello' , common . expectsError ( ) ) ;
9394
95+ // TODO(@jasnell): When close is called, it will cause the write
96+ // handlers to be canceled, which results in the error that
97+ // destroys the stream. Unfortunately there's currently a bug
98+ // that does not emit that error on next tick that still needs
99+ // to be tracked down. Setting the error handler before calling
100+ // close works for now but the error should be emitted on
101+ // next tick.
94102 stream . on ( 'error' , common . mustCall ( ( ) => {
95103 assert . strictEqual ( stream . aborted , true ) ;
96104 } ) ) ;
97105
106+ stream . close ( 1 ) ;
107+
108+ stream . on ( 'end' , common . mustNotCall ( ) ) ;
109+
98110 stream . on ( 'close' , common . mustCall ( ( ) => {
99- debug ( 'Bidirectional, Client-initiated stream %d closed on client' ,
100- stream . id ) ;
101111 countdown . dec ( ) ;
102112 } ) ) ;
103113
0 commit comments