@@ -41,25 +41,29 @@ server.on('session', common.mustCall((session) => {
41
41
session . on ( 'secure' , common . mustCall ( ( servername , alpn , cipher ) => {
42
42
const uni = session . openStream ( { halfOpen : true } ) ;
43
43
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
+
48
59
uni . close ( 3 ) ;
49
60
50
61
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 ( ) ) ;
56
63
uni . on ( 'close' , common . mustCall ( ( ) => {
57
64
debug ( 'Unidirectional, Server-initiated stream %d closed on server' ,
58
65
uni . id ) ;
59
66
} ) ) ;
60
- uni . on ( 'error' , common . mustCall ( ( ) => {
61
- assert . strictEqual ( uni . aborted , true ) ;
62
- } ) ) ;
63
67
64
68
debug ( 'Unidirectional, Server-initiated stream %d opened' , uni . id ) ;
65
69
} ) ) ;
@@ -86,18 +90,24 @@ server.on('ready', common.mustCall(() => {
86
90
87
91
const stream = req . openStream ( ) ;
88
92
89
- stream . write ( 'hello' , common . mustCall ( ) ) ;
90
- stream . close ( 1 ) ;
91
-
92
- stream . on ( 'end' , common . mustNotCall ( ) ) ;
93
+ stream . write ( 'hello' , common . expectsError ( ) ) ;
93
94
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.
94
102
stream . on ( 'error' , common . mustCall ( ( ) => {
95
103
assert . strictEqual ( stream . aborted , true ) ;
96
104
} ) ) ;
97
105
106
+ stream . close ( 1 ) ;
107
+
108
+ stream . on ( 'end' , common . mustNotCall ( ) ) ;
109
+
98
110
stream . on ( 'close' , common . mustCall ( ( ) => {
99
- debug ( 'Bidirectional, Client-initiated stream %d closed on client' ,
100
- stream . id ) ;
101
111
countdown . dec ( ) ;
102
112
} ) ) ;
103
113
0 commit comments