33const common = require ( '../common' ) ;
44if ( ! common . hasCrypto )
55 common . skip ( 'missing crypto' ) ;
6+ const assert = require ( 'assert' ) ;
67const http2 = require ( 'http2' ) ;
78const net = require ( 'net' ) ;
89
@@ -12,6 +13,7 @@ const {
1213
1314const server = http2 . createServer ( ) ;
1415server . on ( 'stream' , common . mustCall ( ( stream ) => {
16+ stream . on ( 'error' , ( err ) => assert . strictEqual ( err . code , 'ECONNRESET' ) ) ;
1517 stream . respondWithFile ( process . execPath , {
1618 [ HTTP2_HEADER_CONTENT_TYPE ] : 'application/octet-stream'
1719 } ) ;
@@ -22,16 +24,9 @@ server.listen(0, common.mustCall(() => {
2224 const req = client . request ( ) ;
2325
2426 req . on ( 'response' , common . mustCall ( ( ) => { } ) ) ;
25- req . on ( 'data' , common . mustCall ( ( ) => {
27+ req . on ( 'data' , common . mustCallAtLeast ( ( ) => {
2628 net . Socket . prototype . destroy . call ( client . socket ) ;
2729 server . close ( ) ;
2830 } ) ) ;
2931 req . end ( ) ;
3032} ) ) ;
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