3
3
const common = require ( '../common' ) ;
4
4
if ( ! common . hasCrypto )
5
5
common . skip ( 'missing crypto' ) ;
6
+ const assert = require ( 'assert' ) ;
6
7
const http2 = require ( 'http2' ) ;
7
8
const net = require ( 'net' ) ;
8
9
@@ -12,6 +13,7 @@ const {
12
13
13
14
const server = http2 . createServer ( ) ;
14
15
server . on ( 'stream' , common . mustCall ( ( stream ) => {
16
+ stream . on ( 'error' , ( err ) => assert . strictEqual ( err . code , 'ECONNRESET' ) ) ;
15
17
stream . respondWithFile ( process . execPath , {
16
18
[ HTTP2_HEADER_CONTENT_TYPE ] : 'application/octet-stream'
17
19
} ) ;
@@ -22,16 +24,9 @@ server.listen(0, common.mustCall(() => {
22
24
const req = client . request ( ) ;
23
25
24
26
req . on ( 'response' , common . mustCall ( ( ) => { } ) ) ;
25
- req . on ( 'data' , common . mustCall ( ( ) => {
27
+ req . on ( 'data' , common . mustCallAtLeast ( ( ) => {
26
28
net . Socket . prototype . destroy . call ( client . socket ) ;
27
29
server . close ( ) ;
28
30
} ) ) ;
29
31
req . end ( ) ;
30
32
} ) ) ;
31
-
32
- // TODO(addaleax): This is a *hack*. HTTP/2 needs to have a proper way of
33
- // dealing with this kind of issue.
34
- process . once ( 'uncaughtException' , ( err ) => {
35
- if ( err . code === 'ECONNRESET' ) return ;
36
- throw err ;
37
- } ) ;
0 commit comments